pub trait Entity:
Sized
+ Debug
+ DeserializeOwned
+ Serialize {
type OperationData: Debug + OperationData + Clone + Serialize + DeserializeOwned;
type HistoryStep: Debug + HistoryStep;
type Timeline: Debug + Timeline<Self>;
const TYPENAME: &str;
const NAMESPACE: &str;
const FORMAT_VERSION: usize;
// Required methods
fn operations(&self) -> &Operations<Self>
where Self: Sized;
fn create_time(&self) -> &Time
where Self: Sized;
fn edit_time(&self) -> &Time
where Self: Sized;
fn current_head(&self) -> &oid
where Self: Sized;
unsafe fn from_parts(
operations: Operations<Self>,
create_time: Time,
edit_time: Time,
current_head: ObjectId,
) -> Self
where Self: Sized;
// Provided methods
fn id(&self) -> EntityId<Self>
where Self: Sized { ... }
fn snapshot(&self) -> Snapshot<Self> { ... }
}Expand description
Required Associated Constants§
Sourceconst FORMAT_VERSION: usize
const FORMAT_VERSION: usize
The expected format version number, that can be used for data migration/upgrade.
Required Associated Types§
Sourcetype OperationData: Debug + OperationData + Clone + Serialize + DeserializeOwned
type OperationData: Debug + OperationData + Clone + Serialize + DeserializeOwned
The type of Operation this Entity uses.
Sourcetype HistoryStep: Debug + HistoryStep
type HistoryStep: Debug + HistoryStep
A step in the history of a Snapshot's
Timeline.
Required Methods§
Sourcefn operations(&self) -> &Operations<Self>where
Self: Sized,
fn operations(&self) -> &Operations<Self>where
Self: Sized,
Return the Operations that compose this Entity.
Sourcefn create_time(&self) -> &Timewhere
Self: Sized,
fn create_time(&self) -> &Timewhere
Self: Sized,
Return the lamport::Time that was set, when this Entity was
first created.
Sourcefn edit_time(&self) -> &Timewhere
Self: Sized,
fn edit_time(&self) -> &Timewhere
Self: Sized,
Return the lamport::Time that was set, when this Entity was last
edited.
Sourcefn current_head(&self) -> &oidwhere
Self: Sized,
fn current_head(&self) -> &oidwhere
Self: Sized,
Return the commit object id of the last commit that added
operations to this Entity.
Sourceunsafe fn from_parts(
operations: Operations<Self>,
create_time: Time,
edit_time: Time,
current_head: ObjectId,
) -> Selfwhere
Self: Sized,
unsafe fn from_parts(
operations: Operations<Self>,
create_time: Time,
edit_time: Time,
current_head: ObjectId,
) -> Selfwhere
Self: Sized,
Construct this instance from the data stored on disk.
This function cannot return an Error, because the previous decoding
functions (e.g.,
Operation::from_value) should
have already sorted out invalid values.
§Note
This function is probably not what you want. It is only useful, if your
want to create this Entity from it’s on disk serialization (or
from a cache.)
§Safety
You need to uphold following invariants:
- The
creation_timeandedit_timemust be valid for the repository at this time (i.e., they should have been computed through witnessing the other clocks.) - The
current_headmust be the actual current head (i.e.,operationsmust be computable by starting a commit traversal from this point).
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.