pub trait NodeDelegate:
Send
+ Sync
+ 'static {
// Provided methods
fn node_meta(&self, limit: usize) -> impl Future<Output = Meta> + Send { ... }
fn notify_message(
&self,
msg: Cow<'_, [u8]>,
) -> impl Future<Output = ()> + Send { ... }
fn broadcast_messages<F>(
&self,
limit: usize,
encoded_len: F,
) -> impl Future<Output = impl Iterator<Item = Bytes> + Send> + Send
where F: Fn(Bytes) -> (usize, Bytes) + Send + Sync + 'static { ... }
fn local_state(&self, join: bool) -> impl Future<Output = Bytes> + Send { ... }
fn merge_remote_state(
&self,
buf: &[u8],
join: bool,
) -> impl Future<Output = ()> + Send { ... }
}Expand description
Used to manage node related events.
Provided Methods§
Sourcefn node_meta(&self, limit: usize) -> impl Future<Output = Meta> + Send
fn node_meta(&self, limit: usize) -> impl Future<Output = Meta> + Send
Used to retrieve meta-data about the current node when broadcasting an alive message. It’s length is limited to the given byte size. This metadata is available in the NodeState structure.
Sourcefn notify_message(&self, msg: Cow<'_, [u8]>) -> impl Future<Output = ()> + Send
fn notify_message(&self, msg: Cow<'_, [u8]>) -> impl Future<Output = ()> + Send
Called when a user-data message is received. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop. Additionally, the byte slice may be modified after the call returns, so it should be copied if needed
Sourcefn broadcast_messages<F>(
&self,
limit: usize,
encoded_len: F,
) -> impl Future<Output = impl Iterator<Item = Bytes> + Send> + Send
fn broadcast_messages<F>( &self, limit: usize, encoded_len: F, ) -> impl Future<Output = impl Iterator<Item = Bytes> + Send> + Send
Called when user data messages can be broadcast. It can return a list of buffers to send. Each buffer should assume an overhead as provided with a limit on the total byte size allowed. The total byte size of the resulting data to send must not exceed the limit. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop.
The encoded_len function accepts a bytes, and will return
the same bytes back and the encoded length of the message.
Sourcefn local_state(&self, join: bool) -> impl Future<Output = Bytes> + Send
fn local_state(&self, join: bool) -> impl Future<Output = Bytes> + Send
Used for a TCP Push/Pull. This is sent to
the remote side in addition to the membership information. Any
data can be sent here. See merge_remote_state as well. The join
boolean indicates this is for a join instead of a push/pull.
Sourcefn merge_remote_state(
&self,
buf: &[u8],
join: bool,
) -> impl Future<Output = ()> + Send
fn merge_remote_state( &self, buf: &[u8], join: bool, ) -> impl Future<Output = ()> + Send
Invoked after a TCP Push/Pull. This is the
state received from the remote side and is the result of the
remote side’s local_state call. The ‘join’
boolean indicates this is for a join instead of a push/pull.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".