Skip to main content

SendMessage

Enum SendMessage 

Source
pub enum SendMessage {
    StableResult(u64, Peer, bool, bool, Vec<u8>),
    StableConnect(u64, Peer, Vec<u8>),
    StableDisconnect(PeerId),
    Connect(Peer),
    DisConnect(Peer),
    Data(u64, PeerId, Vec<u8>),
    Broadcast(Broadcast, Vec<u8>),
    Stream(u32, StreamType, Vec<u8>),
    NetworkState(StateRequest, Sender<StateResponse>),
    NetworkReboot,
    NetworkStop,
    OwnEvent(Vec<u8>),
}
Expand description

main send message for outside channel, send from outside to chamomile.

Variants§

§

StableResult(u64, Peer, bool, bool, Vec<u8>)

when peer request for join, outside decide connect or not. params is delivery_feedback_id, peer, is_connect, is_force_close, result info. if delivery_feedback_id = 0 will not feedback. if is_connect is true, it will add to allow directly list. we want to build a better network, add a is_force_close. if is_connect is false, but is_force_close if true, we will use this peer to build our DHT for better connection. if false, we will force close it. In general, you can example as StableResult(0, Peer, is_ok, false, vec![]).

§

StableConnect(u64, Peer, Vec<u8>)

when need add a peer to stable connect, send to chamomile from outside. if success connect, will start a stable connection, and add peer to kad, stables, bootstraps and allowlists. if failure, will send PeerLeave to outside. params is delivery_feedback_id, peer and custom join_info. if delivery_feedback_id = 0 will not feedback.

§

StableDisconnect(PeerId)

when outside want to close a stable connectioned peer. use it force close. params is peer_id.

§

Connect(Peer)

(DHT connected) when outside want to connect a peer. will try connect directly. if connected, chamomile will add to kad and bootstrap. params is Peer.

§

DisConnect(Peer)

(DHT connected) when outside donnot want to connect peer. use it to force close. it will remove from kad and bootstrap list. params is Peer.

§

Data(u64, PeerId, Vec<u8>)

when need send a data to a peer, only need know the peer_id, the chamomile will help you send data to there. params is delivery_feedback_id, peer_id and data_bytes. if delivery_feedback_id = 0 will not feedback.

§

Broadcast(Broadcast, Vec<u8>)

when need broadcast a data to all network, chamomile support some common algorithm, use it, donnot worry. params is broadcast_type and data_bytes

§

Stream(u32, StreamType, Vec<u8>)

(Only Stable connected) Apply for build a stream between nodes. params is u32 stream symbol, and StreamType.

§

NetworkState(StateRequest, Sender<StateResponse>)

Request for return the network current state info. params is request type, and return channel’s sender (async).

§

NetworkReboot

When receive ReceiveMessage::NetworkLost, want to reboot network, it can use.

§

NetworkStop

When want to close p2p network.

§

OwnEvent(Vec<u8>)

when want to broadcast message with same PeerId.

Trait Implementations§

Source§

impl Debug for SendMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V