pub struct Registry { /* private fields */ }Expand description
Ordered collection of readers. First definite match wins; otherwise best confidence.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn register(&mut self, reader: Box<dyn FormatReader>)
pub fn register(&mut self, reader: Box<dyn FormatReader>)
Add a reader at the end of the detection order (and make its assurance profile known).
Sourcepub fn strict(self, on: bool) -> Self
pub fn strict(self, on: bool) -> Self
Strict mode (--strict, MCP strict: true): every dataset this registry opens refuses,
with exit 6 and a hint, to return outputs its file’s assurance does not validate
(assurance.strict_refuses: an unvalidated variant, an undecoded structure or an unapplied
calibration affecting them). check and info --view structure are never refused.
Sourcepub fn with(self, reader: Box<dyn FormatReader>) -> Self
pub fn with(self, reader: Box<dyn FormatReader>) -> Self
Builder form of Registry::register.
Sourcepub fn descriptors(&self) -> Vec<FormatDescriptor>
pub fn descriptors(&self) -> Vec<FormatDescriptor>
Descriptors of every registered reader, in detection order.
Sourcepub fn by_id(&self, id: &str) -> Option<&dyn FormatReader>
pub fn by_id(&self, id: &str) -> Option<&dyn FormatReader>
The reader with this format id, if registered.
Sourcepub fn detect(&self, path: &Path) -> Result<(&dyn FormatReader, Detection)>
pub fn detect(&self, path: &Path) -> Result<(&dyn FormatReader, Detection)>
Read the head of the file and ask every reader. A directory (a vendor “folder format”
such as a Bruker .d) is offered to every reader with an empty head; readers that accept
directories recognise them by their path and contents.
Sourcepub fn detect_input(
&self,
input: &Input,
) -> Result<(&dyn FormatReader, Detection)>
pub fn detect_input( &self, input: &Input, ) -> Result<(&dyn FormatReader, Detection)>
Sourcepub fn guard(&self, ds: Box<dyn Dataset>) -> Result<Box<dyn Dataset>>
pub fn guard(&self, ds: Box<dyn Dataset>) -> Result<Box<dyn Dataset>>
In strict mode, wrap ds so it refuses unvalidated outputs; otherwise return it as is.
Sourcepub fn open_input(&self, input: &Input) -> Result<(Detection, Box<dyn Dataset>)>
pub fn open_input(&self, input: &Input) -> Result<(Detection, Box<dyn Dataset>)>
Detect and open any Input. Readers that only read local files report other inputs
as unsupported (exit 6).
Sourcepub fn detect_bytes(
&self,
head: &[u8],
name: &Path,
) -> Result<(&dyn FormatReader, Detection)>
pub fn detect_bytes( &self, head: &[u8], name: &Path, ) -> Result<(&dyn FormatReader, Detection)>
Detect from bytes already in memory (the first up to SNIFF_LEN bytes of a stream,
e.g. standard input). name stands in for the path readers may consult for an extension.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !UnwindSafe for Registry
impl Freeze for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
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