use crate::core::store::{DataInput, DataOutput};
use crate::core::util::error::lucene_error::Result;
use crate::core::util::fst_impl::outputs::Outputs;
use std::borrow::Cow;
use std::fmt::{Display, Formatter};
use std::sync::LazyLock;
pub static SINGLETON: LazyLock<NoOutputs> = LazyLock::new(NoOutputs::default);
#[derive(Clone, Default)]
pub struct NoOutputs;
impl NoOutputs {
pub fn get_singleton() -> &'static NoOutputs {
&SINGLETON
}
}
impl Display for NoOutputs {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", std::any::type_name::<Self>())
}
}
impl Outputs for NoOutputs {
type V = ();
fn common(&self, a: &Option<()>, b: &Option<()>) -> Option<()> {
debug_assert!(a.is_none() && b.is_none());
None
}
fn subtract(&self, output: &Option<()>, inc: &Option<()>) -> Option<()> {
debug_assert!(output.is_none() && inc.is_none());
None
}
fn add<'a>(&self, prefix: &'a Option<()>, output: &'a Option<()>) -> Option<Cow<'a, ()>> {
debug_assert!(prefix.is_none() && output.is_none());
None
}
fn write<DO>(&self, _output: &Option<()>, _out: &mut DO) -> Result<()>
where
DO: DataOutput,
{
Ok(())
}
fn read<DI>(&self, _input: &mut DI) -> Result<Option<()>>
where
DI: DataInput,
{
Ok(None)
}
fn output_to_string(&self, _output: &Option<()>) -> String {
String::new()
}
fn merge(&self, first: &Option<()>, second: &Option<()>) -> Result<Option<()>> {
debug_assert!(first.is_none() && second.is_none());
Ok(None)
}
fn ram_bytes_used(&self, _output: &Option<()>) -> i64 {
0
}
}