pub struct ParserRegistry { /* private fields */ }Expand description
An ordered set of format parsers.
Implementations§
Source§impl ParserRegistry
impl ParserRegistry
pub fn new() -> Self
pub fn register(&mut self, parser: Box<dyn FormatParser>) -> &mut Self
Sourcepub fn ids(&self) -> Vec<&'static str>
pub fn ids(&self) -> Vec<&'static str>
Registered parser ids, in order (handy for describe/tests).
Sourcepub fn resolve(
&self,
source: &str,
bytes: &[u8],
) -> Result<&dyn FormatParser, AxError>
pub fn resolve( &self, source: &str, bytes: &[u8], ) -> Result<&dyn FormatParser, AxError>
Resolves the parser for source/bytes: a matching file extension wins;
otherwise the highest-confidence content sniff (first registered on a
tie). An unrecognized stream is AxError::UnknownFormat, never a guess.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParserRegistry
impl !RefUnwindSafe for ParserRegistry
impl Send for ParserRegistry
impl Sync for ParserRegistry
impl Unpin for ParserRegistry
impl UnsafeUnpin for ParserRegistry
impl !UnwindSafe for ParserRegistry
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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