Skip to main content

CompositeDelegate

Struct CompositeDelegate 

Source
pub struct CompositeDelegate<I, Address, A = VoidDelegate<I, Address>, C = VoidDelegate<I, Address>, E = VoidDelegate<I, Address>, M = VoidDelegate<I, Address>, N = VoidDelegate<I, Address>, P = VoidDelegate<I, Address>> { /* private fields */ }
Expand description

CompositeDelegate is a helpful struct to split the Delegate into multiple small delegates, so that users do not need to implement full Delegate when they only want to custom some methods in the Delegate.

Implementations§

Source§

impl<I, Address> CompositeDelegate<I, Address>

Source

pub const fn new() -> Self

Create a new CompositeDelegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_alive_delegate<NA>( self, alive_delegate: NA, ) -> CompositeDelegate<I, Address, NA, C, E, M, N, P>

Set the alive delegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_conflict_delegate<NC>( self, conflict_delegate: NC, ) -> CompositeDelegate<I, Address, A, NC, E, M, N, P>

Set the conflict delegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_event_delegate<NE>( self, event_delegate: NE, ) -> CompositeDelegate<I, Address, A, C, NE, M, N, P>

Set the event delegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_merge_delegate<NM>( self, merge_delegate: NM, ) -> CompositeDelegate<I, Address, A, C, E, NM, N, P>

Set the merge delegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_node_delegate<NN>( self, node_delegate: NN, ) -> CompositeDelegate<I, Address, A, C, E, M, NN, P>

Set the node delegate

Source§

impl<I, Address, A, C, E, M, N, P> CompositeDelegate<I, Address, A, C, E, M, N, P>

Source

pub fn with_ping_delegate<NP>( self, ping_delegate: NP, ) -> CompositeDelegate<I, Address, A, C, E, M, N, NP>

Set the ping delegate

Trait Implementations§

Source§

impl<I, Address, A, C, E, M, N, P> AliveDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Error = <A as AliveDelegate>::Error

The error type of the delegate
Source§

type Id = I

The id type of the delegate
Source§

type Address = Address

The address type of the delegate
Source§

async fn notify_alive( &self, peer: Arc<NodeState<Self::Id, Self::Address>>, ) -> Result<(), Self::Error>

Invoked when a message about a live node is received from the network. Returning a non-nil error prevents the node from being considered a peer.
Source§

impl<I, Address, A, C, E, M, N, P> ConflictDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Id = I

The id type of the delegate
Source§

type Address = Address

The address type of the delegate
Source§

async fn notify_conflict( &self, existing: Arc<NodeState<Self::Id, Self::Address>>, other: Arc<NodeState<Self::Id, Self::Address>>, )

Invoked when a name conflict is detected
Source§

impl<I, Address> Default for CompositeDelegate<I, Address>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<I, Address, A, C, E, M, N, P> Delegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Address = Address

The address type of the delegate
Source§

type Id = I

The id type of the delegate
Source§

impl<I, Address, A, C, E, M, N, P> EventDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Id = I

The id type of the delegate
Source§

type Address = Address

The address type of the delegate
Source§

async fn notify_join(&self, node: Arc<NodeState<Self::Id, Self::Address>>)

Invoked when a node is detected to have joined the cluster
Source§

async fn notify_leave(&self, node: Arc<NodeState<Self::Id, Self::Address>>)

Invoked when a node is detected to have left the cluster
Source§

async fn notify_update(&self, node: Arc<NodeState<Self::Id, Self::Address>>)

Invoked when a node is detected to have updated, usually involving the meta data.
Source§

impl<I, Address, A, C, E, M, N, P> MergeDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Error = <M as MergeDelegate>::Error

The error type of the delegate
Source§

type Id = I

The id type of the delegate
Source§

type Address = Address

The address type of the delegate
Source§

async fn notify_merge( &self, peers: Arc<[NodeState<Self::Id, Self::Address>]>, ) -> Result<(), Self::Error>

Invoked when a merge could take place. Provides a list of the nodes known by the peer. If the return value is Err, the merge is canceled.
Source§

impl<I, Address, A, C, E, M, N, P> NodeDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

async fn node_meta(&self, limit: usize) -> Meta

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.
Source§

async fn notify_message(&self, msg: Cow<'_, [u8]>)

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
Source§

async fn broadcast_messages<F>( &self, limit: usize, encoded_len: F, ) -> impl Iterator<Item = Bytes> + Send
where F: Fn(Bytes) -> (usize, Bytes) + Send + Sync + 'static,

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. Read more
Source§

async fn local_state(&self, join: bool) -> Bytes

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.
Source§

async fn merge_remote_state(&self, buf: &[u8], join: bool)

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.
Source§

impl<I, Address, A, C, E, M, N, P> PingDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Id = I

The id type of the delegate
Source§

type Address = Address

The address type of the delegate
Source§

async fn ack_payload(&self) -> Bytes

Invoked when an ack is being sent; the returned bytes will be appended to the ack
Source§

async fn notify_ping_complete( &self, node: Arc<NodeState<Self::Id, Self::Address>>, rtt: Duration, payload: Bytes, )

Invoked when an ack for a ping is received
Source§

fn disable_reliable_pings(&self, target: &Self::Id) -> bool

Invoked when we want to send a ping message to target by promised connection. Return true if the target node does not expect ping message from promised connection.

Auto Trait Implementations§

§

impl<I, Address, A, C, E, M, N, P> Freeze for CompositeDelegate<I, Address, A, C, E, M, N, P>
where A: Freeze, C: Freeze, E: Freeze, M: Freeze, N: Freeze, P: Freeze,

§

impl<I, Address, A, C, E, M, N, P> RefUnwindSafe for CompositeDelegate<I, Address, A, C, E, M, N, P>

§

impl<I, Address, A, C, E, M, N, P> Send for CompositeDelegate<I, Address, A, C, E, M, N, P>
where A: Send, C: Send, E: Send, M: Send, N: Send, P: Send, I: Send, Address: Send,

§

impl<I, Address, A, C, E, M, N, P> Sync for CompositeDelegate<I, Address, A, C, E, M, N, P>
where A: Sync, C: Sync, E: Sync, M: Sync, N: Sync, P: Sync, I: Sync, Address: Sync,

§

impl<I, Address, A, C, E, M, N, P> Unpin for CompositeDelegate<I, Address, A, C, E, M, N, P>
where A: Unpin, C: Unpin, E: Unpin, M: Unpin, N: Unpin, P: Unpin, I: Unpin, Address: Unpin,

§

impl<I, Address, A, C, E, M, N, P> UnsafeUnpin for CompositeDelegate<I, Address, A, C, E, M, N, P>

§

impl<I, Address, A, C, E, M, N, P> UnwindSafe for CompositeDelegate<I, Address, A, C, E, M, N, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more