pub struct Dictionary {
content: Box<dyn DictReader>,
index: Box<dyn IndexReader>,
metadata: Metadata,
}Expand description
A dictionary wrapper.
A dictionary is made up of a *.dict or *.dict.dz file with the actual content and a
*.index file with a list of all headwords and with positions in the dict file + length
information. It provides a convenience function to look up headwords directly, without caring
about the details of the index and the underlying dict format.
Fields§
§content: Box<dyn DictReader>§index: Box<dyn IndexReader>§metadata: MetadataImplementations§
Source§impl Dictionary
impl Dictionary
Sourcepub fn lookup(
&mut self,
word: &str,
fuzzy: bool,
) -> Result<Vec<[String; 2]>, DictError>
pub fn lookup( &mut self, word: &str, fuzzy: bool, ) -> Result<Vec<[String; 2]>, DictError>
Look up a word in a dictionary.
Words are looked up in the index and then retrieved from the dict file. If no word was found, the returned vector is empty. Errors result from the parsing of the underlying files.
Sourcepub fn metadata(&mut self, name: &str) -> Result<String, DictError>
pub fn metadata(&mut self, name: &str) -> Result<String, DictError>
Retreive metadata from the dictionaries.
The metadata headwords start with 00-database- or 00database.
Sourcepub fn short_name(&mut self) -> Result<String, DictError>
pub fn short_name(&mut self) -> Result<String, DictError>
Get the short name.
This returns the short name of a dictionary. This corresponds to the
value passed to the -s option of dictfmt.
Auto Trait Implementations§
impl Freeze for Dictionary
impl !RefUnwindSafe for Dictionary
impl !Send for Dictionary
impl !Sync for Dictionary
impl Unpin for Dictionary
impl !UnwindSafe for Dictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.