pub trait Ent:
AsAny
+ DynClone
+ Send
+ Sync {
Show 28 methods
// Required methods
fn id(&self) -> Id;
fn set_id(&mut self, id: Id);
fn type(&self) -> &str;
fn created(&self) -> u64;
fn last_updated(&self) -> u64;
fn mark_updated(&mut self) -> Result<(), EntMutationError>;
fn field_definitions(&self) -> Vec<FieldDefinition>;
fn field(&self, name: &str) -> Option<Value>;
fn update_field(
&mut self,
name: &str,
value: Value,
) -> Result<Value, EntMutationError>;
fn edge_definitions(&self) -> Vec<EdgeDefinition>;
fn edge(&self, name: &str) -> Option<EdgeValue>;
fn update_edge(
&mut self,
name: &str,
value: EdgeValue,
) -> Result<EdgeValue, EntMutationError>;
fn connect(&mut self, database: WeakDatabaseRc);
fn disconnect(&mut self);
fn is_connected(&self) -> bool;
fn load_edge(&self, name: &str) -> DatabaseResult<Vec<Box<dyn Ent>>>;
fn clear_cache(&mut self);
fn refresh(&mut self) -> DatabaseResult<()>;
fn commit(&mut self) -> DatabaseResult<()>;
fn remove(&self) -> DatabaseResult<bool>;
// Provided methods
fn field_definition(&self, name: &str) -> Option<FieldDefinition> { ... }
fn field_names(&self) -> Vec<String> { ... }
fn field_type(&self, name: &str) -> Option<ValueType> { ... }
fn fields(&self) -> Vec<Field> { ... }
fn edge_definition(&self, name: &str) -> Option<EdgeDefinition> { ... }
fn edge_names(&self) -> Vec<String> { ... }
fn edge_type(&self, name: &str) -> Option<EdgeValueType> { ... }
fn edges(&self) -> Vec<Edge> { ... }
}Expand description
Represents the interface for a generic entity whose fields and edges can be accessed by str name regardless of compile-time characteristics
Based on https://www.usenix.org/system/files/conference/atc13/atc13-bronson.pdf
Required Methods§
Sourcefn set_id(&mut self, id: Id)
fn set_id(&mut self, id: Id)
Updates the id of this ent, useful for databases that want to adjust the id or when you want to produce a clone of the ent in a database by resetting its id to ephemeral prior to storing it
Sourcefn type(&self) -> &str
fn type(&self) -> &str
Represents a unique type associated with the entity, used for lookups, indexing by type, and conversions
Sourcefn created(&self) -> u64
fn created(&self) -> u64
Represents the time when the instance of the ent was created as the milliseconds since epoch (1970-01-01 00:00:00 UTC)
Sourcefn last_updated(&self) -> u64
fn last_updated(&self) -> u64
Represents the time when the instance of the ent was last updated as the milliseconds since epoch (1970-01-01 00:00:00 UTC)
Sourcefn mark_updated(&mut self) -> Result<(), EntMutationError>
fn mark_updated(&mut self) -> Result<(), EntMutationError>
Updates the time when the instance of the ent was last updated to the current time in milliseconds since epoch (1970-01-01 00:00:00 UTC)
Sourcefn field_definitions(&self) -> Vec<FieldDefinition>
fn field_definitions(&self) -> Vec<FieldDefinition>
Returns a list of definitions for fields contained by the ent
Sourcefn field(&self, name: &str) -> Option<Value>
fn field(&self, name: &str) -> Option<Value>
Returns a copy of the value of the field with the specified name
Sourcefn update_field(
&mut self,
name: &str,
value: Value,
) -> Result<Value, EntMutationError>
fn update_field( &mut self, name: &str, value: Value, ) -> Result<Value, EntMutationError>
Updates the local value of a field with the specified name, returning the old field value if updated. This will also update the last updated time for the ent.
Sourcefn edge_definitions(&self) -> Vec<EdgeDefinition>
fn edge_definitions(&self) -> Vec<EdgeDefinition>
Returns a list of definitions for edges contained by the ent
Sourcefn edge(&self, name: &str) -> Option<EdgeValue>
fn edge(&self, name: &str) -> Option<EdgeValue>
Returns a copy of the value of the edge with the specified name
Sourcefn update_edge(
&mut self,
name: &str,
value: EdgeValue,
) -> Result<EdgeValue, EntMutationError>
fn update_edge( &mut self, name: &str, value: EdgeValue, ) -> Result<EdgeValue, EntMutationError>
Updates the local value of an edge with the specified name, returning the old edge value if updated. This will also update the last updated time for the ent.
Sourcefn connect(&mut self, database: WeakDatabaseRc)
fn connect(&mut self, database: WeakDatabaseRc)
Connects ent to the given database so all future database-related operations will be performed against this database
Sourcefn disconnect(&mut self)
fn disconnect(&mut self)
Disconnects ent from any associated database. All future database operations will fail with a disconnected database error
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Returns true if ent is currently connected to a database
Sourcefn load_edge(&self, name: &str) -> DatabaseResult<Vec<Box<dyn Ent>>>
fn load_edge(&self, name: &str) -> DatabaseResult<Vec<Box<dyn Ent>>>
Loads the ents connected by the edge with the given name
Requires ent to be connected to a database
Sourcefn clear_cache(&mut self)
fn clear_cache(&mut self)
Clears out any locally-cached data for the ent
Sourcefn refresh(&mut self) -> DatabaseResult<()>
fn refresh(&mut self) -> DatabaseResult<()>
Refreshes ent by checking database for latest version and returning it
Requires ent to be connected to a database
Sourcefn commit(&mut self) -> DatabaseResult<()>
fn commit(&mut self) -> DatabaseResult<()>
Saves the ent to the database, updating this local instance’s id if the database has reported a new id
Requires ent to be connected to a database
Sourcefn remove(&self) -> DatabaseResult<bool>
fn remove(&self) -> DatabaseResult<bool>
Removes self from database, returning true if successful
Requires ent to be connected to a database
Provided Methods§
Sourcefn field_definition(&self, name: &str) -> Option<FieldDefinition>
fn field_definition(&self, name: &str) -> Option<FieldDefinition>
Returns definition for the field with specified name
Sourcefn field_names(&self) -> Vec<String>
fn field_names(&self) -> Vec<String>
Returns a list of names of fields contained by the ent
Sourcefn field_type(&self, name: &str) -> Option<ValueType>
fn field_type(&self, name: &str) -> Option<ValueType>
Returns a copy of the type of the field with the specified name
Sourcefn fields(&self) -> Vec<Field>
fn fields(&self) -> Vec<Field>
Returns a copy of all fields contained by the ent and their associated values
Sourcefn edge_definition(&self, name: &str) -> Option<EdgeDefinition>
fn edge_definition(&self, name: &str) -> Option<EdgeDefinition>
Returns definition for the edge with specified name
Sourcefn edge_names(&self) -> Vec<String>
fn edge_names(&self) -> Vec<String>
Returns a list of names of edges contained by the ent
Sourcefn edge_type(&self, name: &str) -> Option<EdgeValueType>
fn edge_type(&self, name: &str) -> Option<EdgeValueType>
Returns a copy of the type of the edge with the specified name
Implementations§
Source§impl dyn Ent
Implementation for a generic trait object of Ent that provides
methods to downcast into a concrete type
impl dyn Ent
Implementation for a generic trait object of Ent that provides
methods to downcast into a concrete type