pub struct Node {
pub node_id: Vec<u8>,
/* private fields */
}
Expand description
Protocol node with persistence support
Fields§
§node_id: Vec<u8>
Node ID
Implementations§
Source§impl Node
impl Node
Sourcepub async fn new(config: NodeConfig) -> Result<Self, ProtocolError>
pub async fn new(config: NodeConfig) -> Result<Self, ProtocolError>
Create new node
Sourcepub async fn with_persistence(config: NodeConfig) -> Result<Self, ProtocolError>
pub async fn with_persistence(config: NodeConfig) -> Result<Self, ProtocolError>
Create new node with persistence
Sourcepub async fn start(&mut self) -> Result<(), ProtocolError>
pub async fn start(&mut self) -> Result<(), ProtocolError>
Start node
Sourcepub async fn stop(&mut self) -> Result<(), ProtocolError>
pub async fn stop(&mut self) -> Result<(), ProtocolError>
Stop node
Sourcepub async fn handle_message(
&mut self,
message: Message,
) -> Result<(), MessageError>
pub async fn handle_message( &mut self, message: Message, ) -> Result<(), MessageError>
Handle incoming message
Sourcepub async fn get_state(&self) -> ProtocolState
pub async fn get_state(&self) -> ProtocolState
Get current node state
Sourcepub fn has_persistence(&self) -> bool
pub fn has_persistence(&self) -> bool
Check if persistence is enabled
Sourcepub async fn save_state(&self) -> Result<(), ProtocolError>
pub async fn save_state(&self) -> Result<(), ProtocolError>
Save current state
Sourcepub async fn create_backup(
&self,
backup_path: PathBuf,
) -> Result<(), ProtocolError>
pub async fn create_backup( &self, backup_path: PathBuf, ) -> Result<(), ProtocolError>
Create backup
Sourcepub async fn restore_backup(
&self,
backup_path: PathBuf,
) -> Result<(), ProtocolError>
pub async fn restore_backup( &self, backup_path: PathBuf, ) -> Result<(), ProtocolError>
Restore from backup
Source§impl Node
impl Node
Sourcepub async fn get_current_state(
&self,
) -> Result<PersistedState, PersistenceError>
pub async fn get_current_state( &self, ) -> Result<PersistedState, PersistenceError>
Get current state for persistence
Auto Trait Implementations§
impl Freeze for Node
impl !RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more