Trait libimagentryutil::isa::Is

source ·
pub trait Is {
    fn is<T: IsKindHeaderPathProvider>(&self) -> Result<bool>;
    fn set_isflag<T: IsKindHeaderPathProvider>(&mut self) -> Result<()>;
}
Expand description

Trait to check whether an entry is a certain kind of entry

If an entry is marked with a bool flag in the header to contain a certain amount of data (for example a “wiki” entry may provide some meta information in the [wiki] section of its header), this trait provides a check whether the entry has set the flag to true or false.

Note

This trait is solely for library implementations, as convenience functionality for implementing some function like this:

Example


use failure::Fallible as Result;
use libimagentryutil::isa::IsKindHeaderPathProvider;
use libimagentryutil::isa::Is;

trait WikiArticle {
    fn is_wiki_article(&self) -> Result<bool>;
    // ...
}

provide_kindflag_path!(IsWikiEntry, "wiki.is_entry");

impl WikiArticle for ::libimagstore::store::Entry {
    fn is_wiki_article(&self) -> Result<bool> {
        self.is::<IsWikiEntry>()
    }
}

See also

  • Documentation for IsKindHeaderPathProvider
  • Helper macro provide_kindflag_path!()

Required Methods

Implementations on Foreign Types

source

impl Is for Entry

Implementors