use std::marker::PhantomData;
use serde::Serialize;
use serde::de::DeserializeOwned;
use crate::compile::builder::{ExternalPortId, FlowState};
use crate::live_collections::stream::{ExactlyOnce, Ordering, Retries, TotalOrder};
use crate::location::LocationKey;
use crate::staging_util::Invariant;
pub enum NotMany {}
pub enum Many {}
pub struct ExternalBytesPort<M = NotMany> {
pub(crate) process_key: LocationKey,
pub(crate) port_id: ExternalPortId,
pub(crate) _phantom: PhantomData<M>,
}
impl Clone for ExternalBytesPort<Many> {
fn clone(&self) -> Self {
Self {
process_key: self.process_key,
port_id: self.port_id,
_phantom: Default::default(),
}
}
}
pub struct ExternalBincodeSink<
Type,
Many = NotMany,
O: Ordering = TotalOrder,
R: Retries = ExactlyOnce,
> where
Type: Serialize,
{
pub(crate) process_key: LocationKey,
pub(crate) port_id: ExternalPortId,
pub(crate) _phantom: PhantomData<(Type, Many, O, R)>,
}
impl<T: Serialize, O: Ordering, R: Retries> Clone for ExternalBincodeSink<T, Many, O, R> {
fn clone(&self) -> Self {
Self {
process_key: self.process_key,
port_id: self.port_id,
_phantom: Default::default(),
}
}
}
pub struct ExternalBincodeBidi<InType, OutType, M = NotMany> {
pub(crate) process_key: LocationKey,
pub(crate) port_id: ExternalPortId,
pub(crate) _phantom: PhantomData<(InType, OutType, M)>,
}
impl<InT, OutT> Clone for ExternalBincodeBidi<InT, OutT, Many> {
fn clone(&self) -> Self {
Self {
process_key: self.process_key,
port_id: self.port_id,
_phantom: Default::default(),
}
}
}
pub struct ExternalBincodeStream<Type, O: Ordering = TotalOrder, R: Retries = ExactlyOnce>
where
Type: DeserializeOwned,
{
#[cfg_attr(
not(feature = "build"),
expect(unused, reason = "unused without feature")
)]
pub(crate) process_key: LocationKey,
#[cfg_attr(
not(feature = "build"),
expect(unused, reason = "unused without feature")
)]
pub(crate) port_id: ExternalPortId,
pub(crate) _phantom: PhantomData<(Type, O, R)>,
}
pub struct External<'a, Tag> {
pub(crate) key: LocationKey,
pub(crate) flow_state: FlowState,
pub(crate) _phantom: Invariant<'a, Tag>,
}
impl<P> Clone for External<'_, P> {
fn clone(&self) -> Self {
External {
key: self.key,
flow_state: self.flow_state.clone(),
_phantom: PhantomData,
}
}
}