pub struct Tips { /* private fields */ }Expand description
The tips registered, and the tip of the day’s place.
Implementations§
Source§impl Tips
impl Tips
Sourcepub fn add_files(&self, origin: &str, files: &[(&str, &str)]) -> Vec<TipError>
pub fn add_files(&self, origin: &str, files: &[(&str, &str)]) -> Vec<TipError>
Registers tips from files’ text, (name, text) (photos.rate.md
and its text, built in with include_str!), as declared by
origin (a plugin’s id). Returns the files that could not be read;
the others are registered.
Sourcepub fn add_dir(&self, origin: &str, dir: &Path) -> Vec<TipError>
pub fn add_dir(&self, origin: &str, dir: &Path) -> Vec<TipError>
Registers the tips of a folder’s *.md files (a plugin’s tips/
folder shipped beside it), as declared by origin. Returns the
files that could not be read.
Sourcepub fn set_auto(&self, on: bool)
pub fn set_auto(&self, on: bool)
Shows tips by themselves, as cards: once FIRST_AFTER seconds
after the start, then the first time a tip’s surface is entered.
Off by default: the application turns it on.
Sourcepub fn set_clock(&self, clock: SharedClock)
pub fn set_clock(&self, clock: SharedClock)
Reads “now” from a clock (seconds since 1970), for tests.
Sourcepub fn used(&self, app: &AppHandle) -> BTreeSet<String>
pub fn used(&self, app: &AppHandle) -> BTreeSet<String>
The commands a person used (the tips.used setting).
Sourcepub fn mark_used<'a>(
&self,
app: &AppHandle,
commands: impl IntoIterator<Item = &'a str>,
) -> Result<(), String>
pub fn mark_used<'a>( &self, app: &AppHandle, commands: impl IntoIterator<Item = &'a str>, ) -> Result<(), String>
Records commands as used: their tips are not picked any more.
Sourcepub fn seen(&self, app: &AppHandle) -> BTreeMap<String, f64>
pub fn seen(&self, app: &AppHandle) -> BTreeMap<String, f64>
When each tip was shown last (the tips.seen setting).
Sourcepub fn off(&self, app: &AppHandle) -> BTreeSet<String>
pub fn off(&self, app: &AppHandle) -> BTreeSet<String>
The origins whose tips are off (the tips.off setting).
Sourcepub fn set_origin_on(
&self,
app: &AppHandle,
origin: &str,
on: bool,
) -> Result<(), String>
pub fn set_origin_on( &self, app: &AppHandle, origin: &str, on: bool, ) -> Result<(), String>
Turns an origin’s tips (a plugin’s) on or off, the others kept.
Sourcepub fn pick(
&self,
app: &AppHandle,
cx: &WhenContext,
keep: impl Fn(&Tip) -> bool,
) -> Option<Tip>
pub fn pick( &self, app: &AppHandle, cx: &WhenContext, keep: impl Fn(&Tip) -> bool, ) -> Option<Tip>
The tip the rules pick in a context, among those keep accepts
(pick); none when tips are off.
Sourcepub fn refusal(&self, app: &AppHandle, id: &str) -> Option<String>
pub fn refusal(&self, app: &AppHandle, id: &str) -> Option<String>
Why a tip would not be picked now, or None when it would.
Sourcepub fn show(&self, app: &AppHandle, id: &str) -> Result<Tip, String>
pub fn show(&self, app: &AppHandle, id: &str) -> Result<Tip, String>
Shows a tip as a card, whatever the rules say, and records it as shown now.
Sourcepub fn show_next_where(
&self,
app: &AppHandle,
keep: impl Fn(&Tip) -> bool,
) -> Option<Tip>
pub fn show_next_where( &self, app: &AppHandle, keep: impl Fn(&Tip) -> bool, ) -> Option<Tip>
Shows the tip the rules pick in the current context (among those
keep accepts); closes the card when there is none.
Sourcepub fn show_next(&self, app: &AppHandle) -> Option<Tip>
pub fn show_next(&self, app: &AppHandle) -> Option<Tip>
Shows the next tip the rules pick (the card’s “Next tip”): the one shown was recorded, so it is not picked again today.
Sourcepub fn not_now(&self, app: &AppHandle)
pub fn not_now(&self, app: &AppHandle)
Closes the card for now (“Not now”, Escape): the tip may come back another day.
Sourcepub fn got_it(&self, app: &AppHandle) -> Result<(), String>
pub fn got_it(&self, app: &AppHandle) -> Result<(), String>
Dismisses the tip shown for good (“Got it”) and closes the card.
Sourcepub fn turn_off(&self, app: &AppHandle) -> Result<(), String>
pub fn turn_off(&self, app: &AppHandle) -> Result<(), String>
Turns every tip off (the tips.show setting) and closes the card.
pub fn get(&self, id: &str) -> Option<Tip>
Sourcepub fn dismissed(&self, app: &AppHandle) -> BTreeSet<String>
pub fn dismissed(&self, app: &AppHandle) -> BTreeSet<String>
The ids of the tips dismissed (the tips.dismissed setting).
pub fn is_dismissed(&self, app: &AppHandle, id: &str) -> bool
Sourcepub fn dismiss(&self, app: &AppHandle, id: &str) -> Result<(), String>
pub fn dismiss(&self, app: &AppHandle, id: &str) -> Result<(), String>
Dismisses a tip for good, through the tips.dismiss step.
Sourcepub fn reset(&self, app: &AppHandle) -> Result<(), String>
pub fn reset(&self, app: &AppHandle) -> Result<(), String>
Shows every tip again: none dismissed, none held back for having been shown today. The commands used stay recorded: what a person knows does not change, and the browser still shows those tips.
Sourcepub fn of_the_day(&self, app: &AppHandle) -> Option<Tip>
pub fn of_the_day(&self, app: &AppHandle) -> Option<Tip>
The tip of the day: the one in turn among those not dismissed; none when tips are off, all dismissed or closed for the session.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tips
impl RefUnwindSafe for Tips
impl Send for Tips
impl Sync for Tips
impl Unpin for Tips
impl UnsafeUnpin for Tips
impl UnwindSafe for Tips
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more