pub struct ClientState<E, SP> { /* private fields */ }Expand description
Keeps track of client graph state.
Eshould be an implementation ofEngine.SPshould be an implementation ofStorageProvider.
Implementations§
Source§impl<E, SP> ClientState<E, SP>
impl<E, SP> ClientState<E, SP>
Sourcepub const fn new(engine: E, provider: SP) -> ClientState<E, SP>
pub const fn new(engine: E, provider: SP) -> ClientState<E, SP>
Creates a ClientState.
Sourcepub fn provider(&mut self) -> &mut SP
pub fn provider(&mut self) -> &mut SP
Provide access to the StorageProvider.
Source§impl<E, SP> ClientState<E, SP>where
E: Engine,
SP: StorageProvider,
impl<E, SP> ClientState<E, SP>where
E: Engine,
SP: StorageProvider,
Sourcepub fn new_graph(
&mut self,
policy_data: &[u8],
action: <E::Policy as Policy>::Action<'_>,
sink: &mut impl Sink<E::Effect>,
) -> Result<GraphId, ClientError>
pub fn new_graph( &mut self, policy_data: &[u8], action: <E::Policy as Policy>::Action<'_>, sink: &mut impl Sink<E::Effect>, ) -> Result<GraphId, ClientError>
Create a new graph (AKA Team). This graph will start with the initial policy
provided which must be compatible with the engine E. The payload is the initial
init message that will bootstrap the graph facts. Effects produced when processing
the payload are emitted to the sink.
Sourcepub fn commit(
&mut self,
trx: &mut Transaction<SP, E>,
sink: &mut impl Sink<E::Effect>,
) -> Result<(), ClientError>
pub fn commit( &mut self, trx: &mut Transaction<SP, E>, sink: &mut impl Sink<E::Effect>, ) -> Result<(), ClientError>
Commit the Transaction to storage, after merging all temporary heads.
Sourcepub fn add_commands(
&mut self,
trx: &mut Transaction<SP, E>,
sink: &mut impl Sink<E::Effect>,
commands: &[impl Command],
) -> Result<usize, ClientError>
pub fn add_commands( &mut self, trx: &mut Transaction<SP, E>, sink: &mut impl Sink<E::Effect>, commands: &[impl Command], ) -> Result<usize, ClientError>
Add commands to the transaction, writing the results to
sink.
Returns the number of commands that were added.
pub fn update_heads( &mut self, storage_id: GraphId, addrs: impl IntoIterator<Item = Address>, request_heads: &mut PeerCache, ) -> Result<(), ClientError>
Source§impl<E, SP> ClientState<E, SP>where
SP: StorageProvider,
impl<E, SP> ClientState<E, SP>where
SP: StorageProvider,
Sourcepub fn transaction(&mut self, storage_id: GraphId) -> Transaction<SP, E>
pub fn transaction(&mut self, storage_id: GraphId) -> Transaction<SP, E>
Create a new Transaction, used to receive Commands when syncing.
Trait Implementations§
Auto Trait Implementations§
impl<E, SP> Freeze for ClientState<E, SP>
impl<E, SP> RefUnwindSafe for ClientState<E, SP>where
E: RefUnwindSafe,
SP: RefUnwindSafe,
impl<E, SP> Send for ClientState<E, SP>
impl<E, SP> Sync for ClientState<E, SP>
impl<E, SP> Unpin for ClientState<E, SP>
impl<E, SP> UnwindSafe for ClientState<E, SP>where
E: UnwindSafe,
SP: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more