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
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
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
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
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
impl Clone for MessageKind
source§fn clone(&self) -> MessageKind
fn clone(&self) -> MessageKind
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MessageKind
impl Debug for MessageKind
source§impl<'de> Deserialize<'de> for MessageKind
impl<'de> Deserialize<'de> for MessageKind
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl PartialEq<MessageKind> for MessageKind
impl PartialEq<MessageKind> for MessageKind
source§fn eq(&self, other: &MessageKind) -> bool
fn eq(&self, other: &MessageKind) -> bool
self
and other
values to be equal, and is used
by ==
.