use serde::{Deserialize, Serialize};
use crate::schema::WireSchema;
use crate::transport::{FormatPreference, TransportTag};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FeedDescriptor {
pub name: String,
pub schema: WireSchema,
pub transports: Vec<TransportTag>,
pub formats: Vec<FormatPreference>,
pub capabilities: Capabilities,
#[serde(default)]
pub event_time_key: Option<String>,
#[serde(default)]
pub tags: Vec<String>,
#[serde(default)]
pub description: Option<String>,
}
impl FeedDescriptor {
pub fn new(name: impl Into<String>, schema: WireSchema) -> Self {
Self {
name: name.into(),
schema,
transports: Vec::new(),
formats: Vec::new(),
capabilities: Capabilities::minimal(),
event_time_key: None,
tags: Vec::new(),
description: None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Capabilities {
pub can_project: bool,
pub can_filter: bool,
pub can_sample: bool,
}
impl Capabilities {
pub const fn minimal() -> Self {
Self { can_project: true, can_filter: false, can_sample: false }
}
pub const fn all() -> Self {
Self { can_project: true, can_filter: true, can_sample: true }
}
}
impl Default for Capabilities {
fn default() -> Self {
Self::minimal()
}
}