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
Deref
s 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<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.