Skip to main content

NetKernel

Trait NetKernel 

pub trait NetKernel<R>: Send + Sync
where 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>

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,

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,

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

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,

When the system is ready to shutdown, this is called

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<'a, R, T> NetKernel<R> for &'a mut T
where R: Ratchet, T: 'a + NetKernel<R> + ?Sized, &'a mut T: Send + Sync,

§

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, &'a mut T: '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, &'a mut T: '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, &'a mut T: 'async_trait,

§

impl<R, T> NetKernel<R> for Box<T>
where R: Ratchet, T: NetKernel<R> + ?Sized, Box<T>: Send + Sync,

§

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, Box<T>: '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, Box<T>: '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, Box<T>: 'async_trait,

Implementors§

Source§

impl<F, Fut, R: Ratchet> NetKernel<R> for BroadcastKernel<'_, F, Fut, R>

Source§

impl<F, Fut, R: Ratchet> NetKernel<R> for ClientConnectListenerKernel<F, Fut, R>
where F: Fn(CitadelClientServerConnection<R>) -> Fut + Send + Sync, Fut: Future<Output = Result<(), NetworkError>> + Send + Sync,

Source§

impl<F, Fut, R: Ratchet> NetKernel<R> for InternalServiceKernel<'_, F, Fut, R>

Source§

impl<F, Fut, R: Ratchet> NetKernel<R> for PeerConnectionKernel<'_, F, Fut, R>

Source§

impl<F, Fut, R: Ratchet> NetKernel<R> for SingleClientServerConnectionKernel<F, Fut, R>
where F: FnOnce(CitadelClientServerConnection<R>) -> Fut + Send, Fut: Future<Output = Result<(), NetworkError>> + Send,

Source§

impl<R: Ratchet> NetKernel<R> for AcceptFileTransferKernel<R>

Source§

impl<R: Ratchet> NetKernel<R> for EmptyKernel<R>