use crate::Object;
pub type FilterFunc = fn((u32, u16), &mut Object) -> Option<((u32, u16), Object)>;
#[derive(Clone, Default)]
pub struct LoadOptions {
pub password: Option<String>,
pub filter: Option<FilterFunc>,
pub strict: bool,
}
impl std::fmt::Debug for LoadOptions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LoadOptions")
.field("password", &self.password.as_ref().map(|_| "***"))
.field("filter", &self.filter.map(|_| "fn(..)"))
.field("strict", &self.strict)
.finish()
}
}
impl LoadOptions {
pub fn with_password(password: &str) -> Self {
Self {
password: Some(password.to_string()),
..Default::default()
}
}
pub fn with_filter(filter: FilterFunc) -> Self {
Self {
filter: Some(filter),
..Default::default()
}
}
}