pub struct Layer<S> { /* private fields */ }Expand description
A generic layer, which controls access to layer state
Layer is a generic wrapper around some state and controls access to it. It
Derefs to the state it wraps, for easy read access, but prevents any
direct write access.
Instead, each write access to state is reified as a command, which are
processed by Layer::process. Processing a command can result in any
number of events, which can then be used as commands for other layers.
This design takes inspiration from, and uses the nomenclature of, this article: https://thinkbeforecoding.com/post/2021/12/17/functional-event-sourcing-decider
Implementations§
Source§impl Layer<Geometry>
impl Layer<Geometry>
Sourcepub fn define_half_edge(
&mut self,
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeometry,
)
pub fn define_half_edge( &mut self, half_edge: Handle<HalfEdge>, geometry: HalfEdgeGeometry, )
Define the geometry of the provided half-edge
Sourcepub fn define_surface(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeometry,
)
pub fn define_surface( &mut self, surface: Handle<Surface>, geometry: SurfaceGeometry, )
Define the geometry of the provided surface
Source§impl Layer<Objects>
impl Layer<Objects>
Sourcepub fn insert(
&mut self,
object: AnyObject<AboutToBeStored>,
geometry: &Geometry,
validation: &mut Layer<Validation>,
)
pub fn insert( &mut self, object: AnyObject<AboutToBeStored>, geometry: &Geometry, validation: &mut Layer<Validation>, )
Insert an object into the stores
Passes any events produced to the validation layer.
Source§impl Layer<Presentation>
impl Layer<Presentation>
Source§impl Layer<Validation>
impl Layer<Validation>
Sourcepub fn take_errors(&mut self) -> Result<(), ValidationErrors>
pub fn take_errors(&mut self) -> Result<(), ValidationErrors>
Take all errors stored in the validation layer
Source§impl<S> Layer<S>
impl<S> Layer<S>
Sourcepub fn process<C>(
&mut self,
command: C,
events: &mut Vec<C::Event>,
) -> C::Resultwhere
C: Command<S>,
pub fn process<C>(
&mut self,
command: C,
events: &mut Vec<C::Event>,
) -> C::Resultwhere
C: Command<S>,
Process a command
The command is processed synchronously. When this method returns, the state has been updated.
Sourcepub fn into_state(self) -> S
pub fn into_state(self) -> S
Drop this instance, returning the wrapped state
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Layer<S>where
S: Freeze,
impl<S> RefUnwindSafe for Layer<S>where
S: RefUnwindSafe,
impl<S> Send for Layer<S>where
S: Send,
impl<S> Sync for Layer<S>where
S: Sync,
impl<S> Unpin for Layer<S>where
S: Unpin,
impl<S> UnwindSafe for Layer<S>where
S: UnwindSafe,
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
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>
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>
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)
&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)
&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> DowncastSync for T
impl<T> DowncastSync for T
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.