Trait citadel_sdk::prelude::NetKernel
pub trait NetKernel: Send + Sync {
// Required methods
fn load_remote(
&mut self,
node_remote: NodeRemote,
) -> Result<(), NetworkError>;
fn on_start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn on_node_event_received<'life0, 'async_trait>(
&'life0 self,
message: NodeResult,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn on_stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
The NetKernel is the thread-safe interface between the single-threaded OR multi-threaded async protocol and your network application
Required Methods§
fn load_remote(&mut self, node_remote: NodeRemote) -> Result<(), NetworkError>
fn load_remote(&mut self, node_remote: NodeRemote) -> Result<(), NetworkError>
when the kernel executes, it will be given a handle to the server
fn on_start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
After the server remote is passed to the kernel, this function will be called once to allow the application to make any initial calls
fn on_node_event_received<'life0, 'async_trait>(
&'life0 self,
message: NodeResult,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_node_event_received<'life0, 'async_trait>(
&'life0 self,
message: NodeResult,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
When the server processes a valid entry, the value is sent here. Each call to ‘on_node_event_received’ is done concurrently (but NOT in parallel). This allows code inside this function to await without blocking new incoming messages