Trait NetKernel
pub trait NetKernel<R>: Send + Syncwhere
R: Ratchet,{
// Required methods
fn load_remote(
&mut self,
node_remote: NodeRemote<R>,
) -> 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<R>,
) -> 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<R>,
) -> Result<(), NetworkError>
fn load_remote( &mut self, node_remote: NodeRemote<R>, ) -> 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<R>,
) -> 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<R>,
) -> 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
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".