Enum agde::MessageKind

source ·
pub enum MessageKind {
Show 16 variants Hello(Capabilities), Welcome { recipient: Option<Uuid>, info: Capabilities, }, InvalidUuid(Uuid), MismatchingVersions(Uuid), Event(Event), FastForward(Request), FastForwardReply(Response), Sync(Request), SyncReply(Response), HashCheck(Request), HashCheckReply(Response), LogCheck { conversation_uuid: Uuid, check: LogCheck, }, LogCheckReply { conversation_uuid: Uuid, check: LogCheck, }, Cancelled(Uuid), Disconnect, User { recipient: Option<Uuid>, data: Vec<u8>, },
}
Expand description

The kinds of messages with their data. Part of a Message.

On direct messages, send a conversation UUID which can be Self::Cancelled.

Variants§

§

Hello(Capabilities)

The client sending this is connecting to the network.

Will declare it’s capabilities.

Replies

Expects a Self::Welcome, Self::InvalidUuid, or Self::MismatchingVersions.

§

Welcome

Fields

§recipient: Option<Uuid>

The target of this message.

§info: Capabilities

Which capabilities we have.

Response to the Self::Hello message.

These capabilities are our own, giving the remote information about us.

When the inner recipient is None, this updates the other piers’ information about the client. Else, it’s just a response to a greeting.

§

InvalidUuid(Uuid)

The sender of MessageKind::Hello of the contained Uuid uses an occupied UUID.

If a critical count of piers respond with this, change UUID and send Self::Hello again.

§

MismatchingVersions(Uuid)

The Capabilities::version() is not compatible.

The sending client (with the contained Uuid) will not add UUID of the Self::Hello message to the known clients. The sender of the Hello should ignore all future messages from this client.

§

Event(Event)

A client has new data to share.

§

FastForward(Request)

A client tries to get the most recent data. Contains the list of which documents were edited and size at last session.

Replies

You should respond with a Self::FastForwardReply. That contains which resources you should sync.

Then, send a Self::Sync request and handle the actual data transmission.

§

FastForwardReply(Response)

A reply to a Self::FastForward request.

§

Sync(Request)

A request to get the diffs and sync the specified resources.

§

SyncReply(Response)

The response with hashes of the specified resources.

§

HashCheck(Request)

Requests all the hashes of all the resources specified in resource::Matcher.

§

HashCheckReply(Response)

A reply with all the hashes of all the requested files.

§

LogCheck

Fields

§conversation_uuid: Uuid

The UUID of this check conversation.

§check: LogCheck

The data of the check.

Checks the internal event UUID log.

Replies

Always send back a Self::LogCheckReply to tell others which “version” you have.

Wait a few seconds (e.g. 10) and then call Manager::assure_log_check. If any discrepancy is found, you should send back a Self::HashCheck. If everything is ok, don’t respond.

§

LogCheckReply

Fields

§conversation_uuid: Uuid

The UUID of this check conversation.

§check: LogCheck

The data of the check.

A reply to Self::LogCheck.

This is used to determine which “version” of the data is the correct one. This should not be responded to, but maybe kept a few seconds to keep the piers with the “correct version”.

§

Cancelled(Uuid)

The target client cancelled the request.

This may be the result of too many requests. Should not be sent as a signal of not supporting the feature.

If a pier requests a check from all and we’ve reached our limit, don’t send this.

§

Disconnect

The sender is disconnecting.

§

User

Fields

§recipient: Option<Uuid>

The recipient for this message. Will be sent and accepted by all if this is None.

§data: Vec<u8>

The data the user wants to transmit to recipient.

Data sent by the user for other users. This can be useful when wanting to send other metadata along with the usual message exchange.

Trait Implementations§

source§

impl Clone for MessageKind

source§

fn clone(&self) -> MessageKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MessageKind

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for MessageKind

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<MessageKind> for MessageKind

source§

fn eq(&self, other: &MessageKind) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for MessageKind

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for MessageKind

source§

impl StructuralEq for MessageKind

source§

impl StructuralPartialEq for MessageKind

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,