use core::time::Duration;
use heapless::Vec;
use serde::{Deserialize, Serialize};
use super::{COMMAND_SAMPLE_MAX, SyncResponseMessage, requester::SyncRequestMessage};
use crate::{Address, GraphId};
#[derive(Serialize, Deserialize, Debug)]
pub 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 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: SyncResponseMessage,
graph_id: GraphId,
},
Hello(SyncHelloType),
}
#[derive(Serialize, Deserialize, Debug)]
pub enum SubscribeResult {
Success,
TooManySubscriptions,
}