Skip to main content

Tips

Struct Tips 

Source
pub struct Tips { /* private fields */ }
Expand description

The tips registered, and the tip of the day’s place.

Implementations§

Source§

impl Tips

Source

pub fn add(&self, tip: Tip)

Registers a tip (replacing one of the same id).

Source

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.

Source

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.

Source

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.

Source

pub fn auto(&self) -> bool

Whether tips show by themselves.

Source

pub fn set_clock(&self, clock: SharedClock)

Reads “now” from a clock (seconds since 1970), for tests.

Source

pub fn now(&self) -> f64

Now, in seconds since 1970.

Source

pub fn used(&self, app: &AppHandle) -> BTreeSet<String>

The commands a person used (the tips.used setting).

Source

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.

Source

pub fn seen(&self, app: &AppHandle) -> BTreeMap<String, f64>

When each tip was shown last (the tips.seen setting).

Source

pub fn off(&self, app: &AppHandle) -> BTreeSet<String>

The origins whose tips are off (the tips.off setting).

Source

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.

Source

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.

Source

pub fn refusal(&self, app: &AppHandle, id: &str) -> Option<String>

Why a tip would not be picked now, or None when it would.

Source

pub fn current(&self) -> Option<Tip>

The tip shown as a card, if any.

Source

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.

Source

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.

Source

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.

Source

pub fn not_now(&self, app: &AppHandle)

Closes the card for now (“Not now”, Escape): the tip may come back another day.

Source

pub fn got_it(&self, app: &AppHandle) -> Result<(), String>

Dismisses the tip shown for good (“Got it”) and closes the card.

Source

pub fn turn_off(&self, app: &AppHandle) -> Result<(), String>

Turns every tip off (the tips.show setting) and closes the card.

Source

pub fn all(&self) -> Vec<Tip>

Every tip, in the order registered.

Source

pub fn get(&self, id: &str) -> Option<Tip>

Source

pub fn enabled(&self, app: &AppHandle) -> bool

Whether tips are shown (the tips.show setting).

Source

pub fn dismissed(&self, app: &AppHandle) -> BTreeSet<String>

The ids of the tips dismissed (the tips.dismissed setting).

Source

pub fn is_dismissed(&self, app: &AppHandle, id: &str) -> bool

Source

pub fn dismiss(&self, app: &AppHandle, id: &str) -> Result<(), String>

Dismisses a tip for good, through the tips.dismiss step.

Source

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.

Source

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.

Source

pub fn turn(&self, app: &AppHandle, back: bool)

Turns to the next tip of the day (back: the previous one).

Source

pub fn close(&self)

Closes the tip of the day for this session.

Trait Implementations§

Source§

impl Debug for Tips

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tips

Source§

fn default() -> Tips

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,