pub struct Resolver { /* private fields */ }Expand description
An inventory of group sources used to resolve group names to node sets
The FromStr implementation of NodeSet uses the global resolver which can be setup to read group sources from the default configuration file as follows:
use nodeset::{NodeSet, Resolver};
fn main() -> Result<(), Box<dyn std::error::Error>> {
Resolver::set_global(Resolver::from_config()?).unwrap();
let ns: NodeSet = "@group".parse()?;
Ok(())
}Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn from_config() -> Result<Self, ConfigurationError>
pub fn from_config() -> Result<Self, ConfigurationError>
Create a new resolver from the default configuration files
Sourcepub fn set_global(resolver: Resolver) -> Result<(), Resolver>
pub fn set_global(resolver: Resolver) -> Result<(), Resolver>
Set the global resolver to use for parsing NodeSet using the FromStr trait
Returns an error if the global resolver is already set
Sourcepub fn get_global() -> &'static Resolver
pub fn get_global() -> &'static Resolver
Get the global resolver
Sourcepub fn resolve<T: IdRange + PartialEq + Clone + Display + Debug>(
&self,
source: Option<&str>,
group: &str,
) -> Result<NodeSet<T>, NodeSetParseError>
pub fn resolve<T: IdRange + PartialEq + Clone + Display + Debug>( &self, source: Option<&str>, group: &str, ) -> Result<NodeSet<T>, NodeSetParseError>
Resolve a group name to a NodeSet
If source is None, the default group source of the resolver is used.
Sourcepub fn list_groups<T: IdRange + PartialEq + Clone + Display + Debug>(
&self,
source: Option<&str>,
) -> NodeSet<T>
pub fn list_groups<T: IdRange + PartialEq + Clone + Display + Debug>( &self, source: Option<&str>, ) -> NodeSet<T>
List groups from a source
If source is None, the default group source of the resolver is used.
Sourcepub fn list_all_groups<T: IdRange + PartialEq + Clone + Display + Debug>(
&self,
) -> impl Iterator<Item = (&str, NodeSet<T>)>
pub fn list_all_groups<T: IdRange + PartialEq + Clone + Display + Debug>( &self, ) -> impl Iterator<Item = (&str, NodeSet<T>)>
List groups from all sources
Returns a list of tuples with the source name and the group name
Sourcepub fn default_source(&self) -> &str
pub fn default_source(&self) -> &str
Returns the default group source for this resolver
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resolver
impl !RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl !UnwindSafe for Resolver
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more