companies_house_api/streaming/operation/
mod.rs

1use serde::{de::DeserializeOwned, Deserialize};
2
3pub mod companies;
4pub mod filings;
5
6pub trait CompaniesHouseStreamingOperation {
7    const ENDPOINT_PATH: &'static str;
8
9    type Data: DeserializeOwned;
10
11    fn endpoint(&self) -> &'static str {
12        Self::ENDPOINT_PATH
13    }
14}
15
16#[derive(Debug, Deserialize)]
17pub struct StreamItem<Data> {
18    pub data: Data,
19    pub event: StreamEvent,
20    pub resource_id: String,
21}
22
23#[derive(Debug, Deserialize)]
24pub struct StreamEvent {
25    pub published_at: String,
26    pub timepoint: usize,
27    pub r#type: StreamEventType,
28}
29
30#[derive(Debug, Deserialize)]
31#[serde(rename_all = "kebab-case")]
32pub enum StreamEventType {
33    Changed,
34    Deleted,
35}