pub struct Entity {
pub id: ID,
pub collection: CollectionId,
pub upstream: Option<Arc<Entity>>,
/* private fields */
}Expand description
An entity represents a unique thing within a collection
Fields§
§id: ID§collection: CollectionId§upstream: Option<Arc<Entity>>Implementations§
Source§impl Entity
impl Entity
pub fn collection(&self) -> CollectionId
pub fn backends(&self) -> &Backends
pub fn to_state(&self) -> Result<State>
pub fn create(id: ID, collection: CollectionId, backends: Backends) -> Self
pub fn from_state( id: ID, collection: CollectionId, state: &State, ) -> Result<Self, RetrievalError>
Sourcepub fn commit(&self) -> Result<Option<Event>>
pub fn commit(&self) -> Result<Option<Event>>
Collect an event which contains all operations for all backends since the last time they were collected Used for transaction commit. TODO: We need to think about rollbacks
pub fn apply_event(&self, event: &Event) -> Result<()>
Sourcepub fn apply_state(&self, state: &State) -> Result<(), RetrievalError>
pub fn apply_state(&self, state: &State) -> Result<(), RetrievalError>
HACK - we probably shouldn’t be stomping on the backends like this
Trait Implementations§
Source§impl Filterable for Entity
impl Filterable for Entity
Source§fn value(&self, name: &str) -> Option<String>
fn value(&self, name: &str) -> Option<String>
TODO Implement this as a typecasted value. eg value
fn collection(&self) -> &str
Auto Trait Implementations§
impl Freeze for Entity
impl RefUnwindSafe for Entity
impl Send for Entity
impl Sync for Entity
impl Unpin for Entity
impl UnwindSafe for Entity
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