use core::time::Duration;
use heapless::Vec;
use serde::{Deserialize, Serialize};
use super::{COMMAND_SAMPLE_MAX, requester::SyncRequestMessage};
use crate::{
Address, GraphId, MaxCut, Prior,
command::{CmdId, Priority},
};
#[derive(Serialize, Deserialize, Debug)]
pub(crate) enum SyncHelloType {
Subscribe {
graph_id: GraphId,
graph_change_delay: Duration,
duration: Duration,
schedule_delay: Duration,
},
Unsubscribe {
graph_id: GraphId,
},
Hello {
graph_id: GraphId,
head: Address,
},
}
#[derive(Serialize, Deserialize, Debug)]
#[allow(clippy::large_enum_variant)]
pub(crate) enum SyncType {
Poll {
request: SyncRequestMessage,
},
Subscribe {
remain_open: u64,
max_bytes: u64,
commands: Vec<Address, COMMAND_SAMPLE_MAX>,
graph_id: GraphId,
},
Unsubscribe {
graph_id: GraphId,
},
Push {
message: super::responder::SyncResponseMessage,
graph_id: GraphId,
},
Hello(SyncHelloType),
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) enum SubscribeResult {
Success,
TooManySubscriptions,
}
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct CommandMeta {
pub(crate) id: CmdId,
pub(crate) priority: Priority,
pub(crate) parent: Prior<Address>,
pub(crate) policy_length: u32,
pub(crate) length: u32,
pub(crate) max_cut: MaxCut,
}