mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
55 lines
1.1 KiB
Rust
55 lines
1.1 KiB
Rust
use vecdb::AnyBoxedIterableVec;
|
|
|
|
#[derive(Clone)]
|
|
pub enum Source<I, T> {
|
|
Compute,
|
|
None,
|
|
Vec(AnyBoxedIterableVec<I, T>),
|
|
}
|
|
|
|
impl<I, T> Source<I, T> {
|
|
pub fn is_compute(&self) -> bool {
|
|
matches!(self, Self::Compute)
|
|
}
|
|
|
|
pub fn is_none(&self) -> bool {
|
|
matches!(self, Self::None)
|
|
}
|
|
|
|
pub fn is_vec(&self) -> bool {
|
|
matches!(self, Self::Vec(_))
|
|
}
|
|
|
|
pub fn vec(self) -> Option<AnyBoxedIterableVec<I, T>> {
|
|
match self {
|
|
Self::Vec(v) => Some(v),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<I, T> From<bool> for Source<I, T> {
|
|
#[inline]
|
|
fn from(value: bool) -> Self {
|
|
if value { Self::Compute } else { Self::None }
|
|
}
|
|
}
|
|
|
|
impl<I, T> From<AnyBoxedIterableVec<I, T>> for Source<I, T> {
|
|
#[inline]
|
|
fn from(value: AnyBoxedIterableVec<I, T>) -> Self {
|
|
Self::Vec(value)
|
|
}
|
|
}
|
|
|
|
impl<I, T> From<Option<AnyBoxedIterableVec<I, T>>> for Source<I, T> {
|
|
#[inline]
|
|
fn from(value: Option<AnyBoxedIterableVec<I, T>>) -> Self {
|
|
if let Some(v) = value {
|
|
Self::Vec(v)
|
|
} else {
|
|
Self::None
|
|
}
|
|
}
|
|
}
|