use std::marker::PhantomData;
#[cfg(feature = "interruptible")]
use interruptible::{Interruptibility, InterruptibilityState};
use crate::StreamOrder;
#[derive(Debug)]
pub struct StreamOpts<'rx, 'intx> {
pub(crate) stream_order: StreamOrder,
#[cfg(feature = "interruptible")]
pub(crate) interruptibility_state: InterruptibilityState<'rx, 'intx>,
#[cfg(feature = "interruptible")]
pub(crate) interrupted_next_item_include: bool,
pub(crate) marker: PhantomData<&'intx &'rx ()>,
}
#[allow(clippy::needless_lifetimes)] impl<'rx, 'intx> StreamOpts<'rx, 'intx> {
pub fn new() -> Self {
Self::default()
}
pub fn rev(mut self) -> Self {
self.stream_order = StreamOrder::Reverse;
self
}
#[cfg(feature = "interruptible")]
pub fn interruptibility_state(
mut self,
interruptibility_state: InterruptibilityState<'rx, 'intx>,
) -> Self {
self.interruptibility_state = interruptibility_state;
self
}
#[cfg(feature = "interruptible")]
pub fn interrupted_next_item_include(mut self, interrupted_next_item_include: bool) -> Self {
self.interrupted_next_item_include = interrupted_next_item_include;
self
}
}
impl Default for StreamOpts<'_, '_> {
fn default() -> Self {
Self {
stream_order: StreamOrder::Forward,
#[cfg(feature = "interruptible")]
interruptibility_state: Interruptibility::NonInterruptible.into(),
#[cfg(feature = "interruptible")]
interrupted_next_item_include: true,
marker: PhantomData,
}
}
}