-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod messages; | ||
pub mod replies; | ||
|
||
pub use messages::*; | ||
pub use replies::{Reply, Response}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use cid::Cid; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_with::skip_serializing_none; | ||
|
||
use crate::{Cursor, Descriptor, Message}; | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct ReadEntry { | ||
#[serde(rename = "messageCid")] | ||
pub cid: Cid, | ||
pub message: Option<Message<Descriptor>>, | ||
} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Read { | ||
pub entry: Option<ReadEntry>, | ||
} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Query { | ||
pub entries: Option<Vec<Cid>>, | ||
pub cursor: Option<Cursor>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pub mod messages; | ||
pub mod protocols; | ||
pub mod records; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use serde_with::skip_serializing_none; | ||
|
||
use crate::SubscriptionID; | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Status { | ||
pub code: i32, | ||
pub detail: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Response { | ||
pub status: Status, | ||
#[serde(flatten)] | ||
pub reply: Reply, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Empty {} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Subscribe { | ||
pub subscription: Option<SubscriptionID>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
#[serde(untagged)] | ||
pub enum Reply { | ||
Empty(Empty), | ||
RecordsRead(records::Read), | ||
RecordsQuery(records::Query), | ||
MessageRead(messages::Read), | ||
MessageQuery(messages::Query), | ||
ProtocolsQuery(protocols::Query), | ||
Subscribe(Subscribe), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use serde_with::skip_serializing_none; | ||
|
||
use crate::{descriptors::protocols, Message}; | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Query { | ||
pub entries: Option<Message<protocols::ConfigureDescriptor>>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use serde_with::skip_serializing_none; | ||
|
||
use crate::{ | ||
descriptors::{records::WriteDescriptor, DeleteDescriptor}, | ||
Cursor, Message, | ||
}; | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct ReadEntry { | ||
#[serde(rename = "recordsWrite")] | ||
pub records_write: Option<Message<WriteDescriptor>>, | ||
#[serde(rename = "recordsDelete")] | ||
pub records_delete: Option<Message<DeleteDescriptor>>, | ||
#[serde(rename = "initialWrite")] | ||
pub initial_write: Option<Message<WriteDescriptor>>, | ||
} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Read { | ||
pub entry: Option<ReadEntry>, | ||
} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct QueryEntry { | ||
#[serde(rename = "initialWrite")] | ||
pub initial_write: Option<Message<WriteDescriptor>>, | ||
#[serde(rename = "encodedData")] | ||
pub encoded_data: Option<String>, | ||
#[serde(flatten)] | ||
pub message: Message<WriteDescriptor>, | ||
} | ||
|
||
#[skip_serializing_none] | ||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct Query { | ||
pub entries: Option<Vec<QueryEntry>>, | ||
pub cursor: Option<Cursor>, | ||
} |