Skip to main content

ObjectSpace

Trait ObjectSpace 

Source
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§

Source

fn entities(&self) -> Vec<EntityInfo>

The entities it knows.

Source

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>

Reads one record by its key.

Source

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>

Marks a record as new or changed, by its key.

Source

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>

Marks a record to go away.

Source

fn changes(&self) -> Vec<Change>

What waits for a commit.

Source

fn commit(&mut self) -> Result<(), SpaceError>

Keeps every change, or none of them.

Source

fn rollback(&mut self)

Throws away every change.

Source

fn on_event(&mut self, watcher: SpaceWatcher)

Calls this when something happens to the space.

Provided Methods§

Source

fn is_modified(&self) -> bool

Whether anything waits for a commit.

Source

fn refresh(&mut self)

Throws away every change and reads again from storage.

Trait Implementations§

Source§

impl ObjectSpace for Box<dyn ObjectSpace>

Source§

fn entities(&self) -> Vec<EntityInfo>

The entities it knows.
Source§

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>

Reads one record by its key.
Source§

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>

Marks a record as new or changed, by its key.
Source§

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>

Marks a record to go away.
Source§

fn changes(&self) -> Vec<Change>

What waits for a commit.
Source§

fn is_modified(&self) -> bool

Whether anything waits for a commit.
Source§

fn commit(&mut self) -> Result<(), SpaceError>

Keeps every change, or none of them.
Source§

fn rollback(&mut self)

Throws away every change.
Source§

fn refresh(&mut self)

Throws away every change and reads again from storage.
Source§

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".

Implementations on Foreign Types§

Source§

impl ObjectSpace for Box<dyn ObjectSpace>

Source§

fn entities(&self) -> Vec<EntityInfo>

Source§

fn query(&self, entity: &str, query: &Query) -> Result<Vec<Object>, SpaceError>

Source§

fn find(&self, entity: &str, key: &Value) -> Result<Option<Object>, SpaceError>

Source§

fn new_object(&mut self, entity: &str) -> Result<Object, SpaceError>

Source§

fn save(&mut self, object: Object) -> Result<(), SpaceError>

Source§

fn insert(&mut self, object: Object) -> Result<(), SpaceError>

Source§

fn delete(&mut self, entity: &str, key: &Value) -> Result<(), SpaceError>

Source§

fn changes(&self) -> Vec<Change>

Source§

fn is_modified(&self) -> bool

Source§

fn commit(&mut self) -> Result<(), SpaceError>

Source§

fn rollback(&mut self)

Source§

fn refresh(&mut self)

Source§

fn on_event(&mut self, watcher: SpaceWatcher)

Implementors§