use crate::transducer::Algorithm;
use std::path::PathBuf;
#[cfg(feature = "cli")]
use crate::cli::args::SerializationFormat;
#[cfg(feature = "cli")]
use crate::repl::state::DictionaryBackend;
#[derive(Debug, Clone)]
pub struct QueryParams {
pub term: String,
pub max_distance: usize,
pub algorithm: Algorithm,
pub prefix: bool,
pub show_distances: bool,
pub limit: Option<usize>,
}
#[derive(Debug, Clone)]
pub enum ModifyOp {
Insert {
terms: Vec<String>,
},
Delete {
terms: Vec<String>,
},
Clear,
}
#[derive(Debug, Clone)]
pub enum IoOp {
Load {
path: PathBuf,
},
Save {
path: PathBuf,
},
Info {
path: Option<PathBuf>,
},
}
#[derive(Debug)]
pub struct CommandResult {
pub output: String,
pub modified: bool,
pub should_exit: bool,
}
impl CommandResult {
pub fn success(output: impl Into<String>) -> Self {
Self {
output: output.into(),
modified: false,
should_exit: false,
}
}
pub fn modified(output: impl Into<String>) -> Self {
Self {
output: output.into(),
modified: true,
should_exit: false,
}
}
pub fn exit(output: impl Into<String>) -> Self {
Self {
output: output.into(),
modified: false,
should_exit: true,
}
}
}
#[cfg(feature = "cli")]
#[derive(Debug, Clone)]
pub struct SerializeParams {
pub path: PathBuf,
pub format: SerializationFormat,
pub overwrite: bool,
}
#[cfg(feature = "cli")]
#[derive(Debug, Clone)]
pub struct DeserializeParams {
pub path: PathBuf,
pub backend: Option<DictionaryBackend>,
pub format: Option<SerializationFormat>,
}
#[cfg(feature = "cli")]
#[derive(Debug, Clone)]
pub struct SerializeResult {
pub term_count: usize,
pub byte_size: u64,
pub format: SerializationFormat,
}
#[cfg(feature = "cli")]
#[derive(Debug, Clone)]
pub struct DeserializeResult {
pub term_count: usize,
pub backend: DictionaryBackend,
pub format: SerializationFormat,
}
#[cfg(feature = "cli")]
#[derive(Debug, Clone)]
pub struct DictInfo {
pub path: PathBuf,
pub term_count: usize,
pub backend: DictionaryBackend,
pub format: SerializationFormat,
pub file_size: u64,
}