Skip to main content

Cx

Struct Cx 

Source
pub struct Cx<'a, B: Backend, T> {
    pub world: &'a mut B::World,
    /* private fields */
}

Fields§

§world: &'a mut B::World

Implementations§

Source§

impl<'a, B: Backend, T: 'static> Cx<'a, B, T>

Source

pub fn new( world: &'a mut B::World, theme: &'a T, mounted: &'a mut Mounted<B, T>, ) -> Self

Source

pub fn theme(&self) -> &'a T

Source

pub fn parent(&self) -> Option<B::Node>

Where a view built now hangs. None at the root.

Source

pub fn effect<P>( &mut self, node: B::Node, value: Prop<B::World, P>, run: impl FnMut(&mut B::World, B::Node, &P) + Send + Sync + 'static, )
where P: PartialEq + Clone + Send + Sync + 'static,

Runs run on node with what value holds: once now, and again whenever a bound value changes to something different, until the node is unmounted. An unset prop never runs it.

This is how a composite follows a bound value: an element reads its own props, and a composite hands one to this.

Source

pub fn spawn(&mut self) -> B::Node

A new, empty node where a view built now hangs. It is the root of every rule set since the last node was spawned.

Source

pub fn build(&mut self, view: impl View<B, T>) -> B::Node

Builds view where a view built now hangs.

Source

pub fn under<R>( &mut self, parent: B::Node, build: impl FnOnce(&mut Self) -> R, ) -> R

Runs build with views hanging under parent.

Source

pub fn at_root<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R

Runs build with views hanging at the root, whatever they were built under. The rules in force still apply.

Source

pub fn scope<R>(&mut self, build: impl FnOnce(&mut Self) -> R) -> R

Runs build in a scope of its own: rules it sets end with it.

Source

pub fn when<C: Condition<B>>(&mut self, set: impl FnOnce(&mut Self))

Runs set with the rules it sets holding only while the root of the view they are set for is in the state C.

On that root they beat its call site, as a state rule does. On a view under it they only fill what that view’s call site left unset, as a set rule does. Either way they beat rules that do not wait on a state.

Source

pub fn root(&mut self, set: impl FnOnce(&mut Self))

Runs set with the rules it sets reaching only the root of the view they are set for: the first node spawned after them.

Source

pub fn defaults(&mut self, set: impl FnOnce(&mut Self))

Runs set with the rules it sets weaker than any that are not, wherever they are: a composite’s defaults, which an app’s rules should restyle.

Source

pub fn set<V: Styled>( &mut self, rule: impl Fn(V, &T) -> V + Send + Sync + 'static, )

Restyles every V built from here to the end of the scope. A call-site value still beats it.

Source

pub fn transition(&mut self, motion: Motion)
where T: MotionTokens,

Makes every element built from here to the end of the scope travel to new values over the theme’s curve for motion, if it says how its values blend.

Source

pub fn transition_over(&mut self, curve: Curve)

As transition, over curve.

Source

pub fn set_field<P, X>(&mut self, path: Cursor<P>, value: X)
where P: FieldPath<Target = Prop<B::World, X>>, P::Source: Styled, X: Clone + Send + Sync + 'static,

Sets the field path names to value, on every view path starts from, from here to the end of the scope. A set rule like set, but one that says which field it sets.

The path may reach into a composite’s own parts: Card::cursor().title().size() sets the size of a card’s title, and of nothing else.

Source

pub fn set_field_with<P, X>( &mut self, path: Cursor<P>, read: impl Fn(&T) -> X + Send + Sync + 'static, )
where P: FieldPath<Target = Prop<B::World, X>>, P::Source: Styled, X: Send + Sync + 'static,

As set_field, with the value read from the theme.

Source

pub fn trace<V: Styled>(&self, field: FieldId) -> Trace

Which set rules in force for a V could decide field.

Source

pub fn show<V: Styled>( &mut self, rule: impl Fn(V, &T) -> V + Send + Sync + 'static, )

Transforms every V built from here to the end of the scope, after its call site, so unlike a set rule it wins over it.

Source

pub fn resolve<V: Styled>(&self, view: V) -> V

view with the rules in force applied: set rules fill what its call site left unset, defaults first, then outer scopes before inner, then show rules transform the result. Rules waiting on a state are left out: an element puts them on top while mounted.

Trait Implementations§

Source§

impl<B: Backend, T> Drop for Cx<'_, B, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, B, T> !RefUnwindSafe for Cx<'a, B, T>

§

impl<'a, B, T> !UnwindSafe for Cx<'a, B, T>

§

impl<'a, B, T> Freeze for Cx<'a, B, T>
where &'a mut <B as Backend>::World: Freeze, &'a T: Freeze, &'a mut Mounted<B, T>: Freeze, Option<<B as Backend>::Node>: Freeze, Vec<ScopeEntry<B>>: Freeze, Marks<B>: Freeze,

§

impl<'a, B, T> Send for Cx<'a, B, T>
where &'a mut <B as Backend>::World: Send, &'a T: Send, &'a mut Mounted<B, T>: Send, Option<<B as Backend>::Node>: Send, Vec<ScopeEntry<B>>: Send, Marks<B>: Send,

§

impl<'a, B, T> Sync for Cx<'a, B, T>
where &'a mut <B as Backend>::World: Sync, &'a T: Sync, &'a mut Mounted<B, T>: Sync, Option<<B as Backend>::Node>: Sync, Vec<ScopeEntry<B>>: Sync, Marks<B>: Sync,

§

impl<'a, B, T> Unpin for Cx<'a, B, T>
where &'a mut <B as Backend>::World: Unpin, &'a T: Unpin, &'a mut Mounted<B, T>: Unpin, Option<<B as Backend>::Node>: Unpin, Vec<ScopeEntry<B>>: Unpin, Marks<B>: Unpin,

§

impl<'a, B, T> UnsafeUnpin for Cx<'a, B, T>
where &'a mut <B as Backend>::World: UnsafeUnpin, &'a T: UnsafeUnpin, &'a mut Mounted<B, T>: UnsafeUnpin, Option<<B as Backend>::Node>: UnsafeUnpin, Vec<ScopeEntry<B>>: UnsafeUnpin, Marks<B>: UnsafeUnpin,

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<V> ScopedExt for V

Source§

fn rules<F>(self, rules: F) -> Rules<Self, F>

This view, built in a scope where rules ran first. Rules marked root reach its root node alone.
Source§

fn when_in<C, F>(self, rules: F) -> When<Self, F, C>

This view, with rules holding while its root node is in the state C. See Cx::when.
Source§

fn transition(self, motion: Motion) -> Transition<Self>

This view, with every element in it travelling to new values over the theme’s curve for motion.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.