diff options
author | Alex Auvolat <alex@adnab.me> | 2020-12-02 20:12:24 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-12-02 20:12:24 +0100 |
commit | 14d34e76f4007e50af89bd47f6ad36f45494c50a (patch) | |
tree | d1a79d397b26f9500917ef5e4eaa6ae70b2d1429 /src/message.rs | |
parent | 46fae5d138cb7c0a74e2a8c7837541f18400ccf4 (diff) | |
download | netapp-14d34e76f4007e50af89bd47f6ad36f45494c50a.tar.gz netapp-14d34e76f4007e50af89bd47f6ad36f45494c50a.zip |
Documentate
Diffstat (limited to 'src/message.rs')
-rw-r--r-- | src/message.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/message.rs b/src/message.rs index bcc5aac..bd54523 100644 --- a/src/message.rs +++ b/src/message.rs @@ -2,6 +2,21 @@ use serde::{Deserialize, Serialize}; pub type MessageKind = u32; +/// This trait should be implemented by all messages your application +/// wants to handle (click to read more). +/// +/// It defines a `KIND`, which should be a **unique** +/// `u32` that distinguishes these messages from other types of messages +/// (it is used by our communication protocol), as well as an associated +/// `Response` type that defines the type of the response that is given +/// to the message. It is your responsibility to ensure that `KIND` is a +/// unique `u32` that is not used by any other protocol messages. +/// All `KIND` values of the form `0x42xxxxxx` are reserved by the netapp +/// crate for internal purposes. +/// +/// A handler for this message has type `Self -> Self::Response`. +/// If you need to return an error, the `Response` type should be +/// a `Result<_, _>`. pub trait Message: Serialize + for<'de> Deserialize<'de> + Send + Sync { const KIND: MessageKind; type Response: Serialize + for<'de> Deserialize<'de> + Send + Sync; |