pub struct Cx<'a, D: Document> {
pub jobs: &'a mut Jobs<Session<D>>,
pub toasts: &'a mut Toasts,
pub settings: &'a mut Settings,
/* private fields */
}Expand description
What the view gets each frame: the session, commands, jobs, toasts and settings.
Fields§
§jobs: &'a mut Jobs<Session<D>>Background work; a job’s apply runs on the session (each edit there is an undo step).
toasts: &'a mut Toasts§settings: &'a mut SettingsApp settings (debounced, saved in the config folder).
Implementations§
Source§impl<D: Document> Cx<'_, D>
impl<D: Document> Cx<'_, D>
Sourcepub fn snapshot(&self) -> Arc<D> ⓘ
pub fn snapshot(&self) -> Arc<D> ⓘ
The current document as an Arc (to keep while calling &mut self methods).
pub fn session(&self) -> &Session<D>
pub fn session_mut(&mut self) -> &mut Session<D>
pub fn ctx(&self) -> &Context
Sourcepub fn dispatch(&mut self, id: &str, params: Value)
pub fn dispatch(&mut self, id: &str, params: Value)
Run a command after the view returns (menus, buttons). Errors are shown as toasts.
Sourcepub fn execute(
&mut self,
id: &str,
params: Value,
) -> Result<Value, CommandError>
pub fn execute( &mut self, id: &str, params: Value, ) -> Result<Value, CommandError>
Run a command now and get its result.
Sourcepub fn edit<R>(&mut self, label: &str, f: impl FnOnce(&mut D) -> R) -> R
pub fn edit<R>(&mut self, label: &str, f: impl FnOnce(&mut D) -> R) -> R
An undoable change made directly by the view (one step called label).
Sourcepub fn edit_merged<R>(
&mut self,
label: &str,
merge_key: &str,
f: impl FnOnce(&mut D) -> R,
) -> R
pub fn edit_merged<R>( &mut self, label: &str, merge_key: &str, f: impl FnOnce(&mut D) -> R, ) -> R
An undoable change folded into the previous one with the same label and key (a drag).
Sourcepub fn view<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn view<T: DeserializeOwned>(&self, key: &str) -> Option<T>
View state (not in the document; ui.set changes it too).
pub fn view_or<T: DeserializeOwned>(&self, key: &str, default: T) -> T
pub fn set_view<T: Serialize + ?Sized>(&mut self, key: &str, value: &T)
Auto Trait Implementations§
impl<'a, D> !RefUnwindSafe for Cx<'a, D>
impl<'a, D> !Sync for Cx<'a, D>
impl<'a, D> !UnwindSafe for Cx<'a, D>
impl<'a, D> Freeze for Cx<'a, D>
impl<'a, D> Send for Cx<'a, D>
impl<'a, D> Unpin for Cx<'a, D>
impl<'a, D> UnsafeUnpin for Cx<'a, D>where
&'a mut Session<D>: UnsafeUnpin,
&'a Registry<Session<D>>: UnsafeUnpin,
&'a mut Jobs<Session<D>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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 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> ⓘ
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