pub trait ObjectSpace {
Show 13 methods
// Required methods
fn entities(&self) -> Vec<EntityInfo>;
fn query(
&self,
entity: &str,
query: &Query,
) -> Result<Vec<Object>, SpaceError>;
fn find(
&self,
entity: &str,
key: &Value,
) -> Result<Option<Object>, SpaceError>;
fn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>;
fn save(&mut self, object: Object) -> Result<(), SpaceError>;
fn insert(&mut self, object: Object) -> Result<(), SpaceError>;
fn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>;
fn changes(&self) -> Vec<Change>;
fn commit(&mut self) -> Result<(), SpaceError>;
fn rollback(&mut self);
fn on_event(&mut self, watcher: SpaceWatcher);
// Provided methods
fn is_modified(&self) -> bool { ... }
fn refresh(&mut self) { ... }
}Expand description
A unit of work over records: what it reads includes its own changes, and nothing
reaches storage until commit. A view has one of these, so canceling a
form throws away only that form’s changes.
Required Methods§
Sourcefn entities(&self) -> Vec<EntityInfo>
fn entities(&self) -> Vec<EntityInfo>
The entities it knows.
Sourcefn find(&self, entity: &str, key: &Value) -> Result<Option<Object>, SpaceError>
fn find(&self, entity: &str, key: &Value) -> Result<Option<Object>, SpaceError>
Reads one record by its key.
Sourcefn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>
fn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>
A record with what a new one starts with, kept only once saved.
Sourcefn save(&mut self, object: Object) -> Result<(), SpaceError>
fn save(&mut self, object: Object) -> Result<(), SpaceError>
Marks a record as new or changed, by its key.
Sourcefn insert(&mut self, object: Object) -> Result<(), SpaceError>
fn insert(&mut self, object: Object) -> Result<(), SpaceError>
Marks a record as new, refusing a key already in use, as a form creating a record has to: it must not take over the record with that key.
Sourcefn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>
fn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>
Marks a record to go away.
Sourcefn commit(&mut self) -> Result<(), SpaceError>
fn commit(&mut self) -> Result<(), SpaceError>
Keeps every change, or none of them.
Sourcefn on_event(&mut self, watcher: SpaceWatcher)
fn on_event(&mut self, watcher: SpaceWatcher)
Calls this when something happens to the space.
Provided Methods§
Sourcefn is_modified(&self) -> bool
fn is_modified(&self) -> bool
Whether anything waits for a commit.
Trait Implementations§
Source§impl ObjectSpace for Box<dyn ObjectSpace>
impl ObjectSpace for Box<dyn ObjectSpace>
Source§fn entities(&self) -> Vec<EntityInfo>
fn entities(&self) -> Vec<EntityInfo>
The entities it knows.
Source§fn query(&self, entity: &str, query: &Query) -> Result<Vec<Object>, SpaceError>
fn query(&self, entity: &str, query: &Query) -> Result<Vec<Object>, SpaceError>
Reads records.
Source§fn find(&self, entity: &str, key: &Value) -> Result<Option<Object>, SpaceError>
fn find(&self, entity: &str, key: &Value) -> Result<Option<Object>, SpaceError>
Reads one record by its key.
Source§fn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>
fn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>
A record with what a new one starts with, kept only once
saved.Source§fn save(&mut self, object: Object) -> Result<(), SpaceError>
fn save(&mut self, object: Object) -> Result<(), SpaceError>
Marks a record as new or changed, by its key.
Source§fn insert(&mut self, object: Object) -> Result<(), SpaceError>
fn insert(&mut self, object: Object) -> Result<(), SpaceError>
Marks a record as new, refusing a key already in use, as a form creating
a record has to: it must not take over the record with that key.
Source§fn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>
fn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>
Marks a record to go away.
Source§fn is_modified(&self) -> bool
fn is_modified(&self) -> bool
Whether anything waits for a commit.
Source§fn on_event(&mut self, watcher: SpaceWatcher)
fn on_event(&mut self, watcher: SpaceWatcher)
Calls this when something happens to the space.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".