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>
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 remove_graph(&mut self, graph_id: GraphId) -> Result<(), ClientError>
pub fn remove_graph(&mut self, graph_id: GraphId) -> Result<(), ClientError>
Remove a graph (AKA Team). The graph commands will be removed from storage.
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>
Sourcepub fn head_address(
&mut self,
storage_id: GraphId,
) -> Result<Address, ClientError>
pub fn head_address( &mut self, storage_id: GraphId, ) -> Result<Address, ClientError>
Returns the address of the head of the graph.
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.
Sourcepub fn session(
&mut self,
storage_id: GraphId,
) -> Result<Session<SP, E>, ClientError>
pub fn session( &mut self, storage_id: GraphId, ) -> Result<Session<SP, E>, ClientError>
Create an ephemeral Session associated with this client.
Sourcepub fn command_exists(&mut self, storage_id: GraphId, address: Address) -> bool
pub fn command_exists(&mut self, storage_id: GraphId, address: Address) -> bool
Checks if a command with the given address exists in the specified graph.
Returns true if the command exists, false if it doesn’t exist or the graph doesn’t exist.
This method is used to determine if we need to sync when a hello message is received.
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.