Trait SharedObject

Source
pub trait SharedObject:
    Send
    + Sync
    + Debug {
Show 23 methods // Required methods fn id(&self) -> SharedObjectId; fn type_name(&self) -> &'static str; fn is_valid<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 SharedMessage, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_message<'life0, 'async_trait>( &'life0 mut self, message: SharedMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn is_merkleized(&self) -> bool; fn get_latest_digest<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn has_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn is_valid_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_digest<'life0, 'async_trait>( &'life0 mut self, digest: String, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn gossip_messages<'life0, 'life1, 'async_trait>( &'life0 self, digest: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedMessage>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_messages_since_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedMessage>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn reset<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn to_json(&self) -> Result<Value>; fn apply_json<'life0, 'async_trait>( &'life0 mut self, data: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn clone_box(&self) -> Box<dyn SharedObject>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; fn on_access<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn on_modify<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn on_delete<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn validate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn metadata(&self) -> HashMap<String, String>;
}
Expand description

Trait for objects that can be shared and synchronized across nodes

Required Methods§

Source

fn id(&self) -> SharedObjectId

Get the unique identifier for this shared object

Source

fn type_name(&self) -> &'static str

Get the type name of this shared object

Source

fn is_valid<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 SharedMessage, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validate if a message is valid for this shared object

Source

fn add_message<'life0, 'async_trait>( &'life0 mut self, message: SharedMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process a validated message and update the object state

Source

fn is_merkleized(&self) -> bool

Check if this object supports merkleized synchronization

Source

fn get_latest_digest<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest state digest for synchronization

Source

fn has_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if the object has a specific digest

Source

fn is_valid_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validate if a digest is valid

Source

fn add_digest<'life0, 'async_trait>( &'life0 mut self, digest: String, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a digest to the object

Source

fn gossip_messages<'life0, 'life1, 'async_trait>( &'life0 self, digest: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get messages for gossip protocol

Source

fn get_messages_since_digest<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get messages since a specific digest

Source

fn get_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current state as a serializable value

Source

fn reset<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reset the object to a clean state

Source

fn to_json(&self) -> Result<Value>

Serialize the object to JSON

Source

fn apply_json<'life0, 'async_trait>( &'life0 mut self, data: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the object from JSON data

Source

fn clone_box(&self) -> Box<dyn SharedObject>

Clone the object as a trait object

Source

fn as_any(&self) -> &dyn Any

Get a reference to self as Any for downcasting

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Get a mutable reference to self as Any for downcasting

Source

fn on_access<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called when the object is accessed

Source

fn on_modify<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called when the object is modified

Source

fn on_delete<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called when the object is deleted

Source

fn validate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Validate the object’s current state

Source

fn metadata(&self) -> HashMap<String, String>

Get object metadata

Trait Implementations§

Source§

impl Clone for Box<dyn SharedObject>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§