Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

Ordered collection of readers. First definite match wins; otherwise best confidence.

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

An empty registry. Readers are consulted in the order they are added.

Source

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).

Source

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.

Source

pub fn is_strict(&self) -> bool

True in strict mode.

Source

pub fn with(self, reader: Box<dyn FormatReader>) -> Self

Builder form of Registry::register.

Source

pub fn descriptors(&self) -> Vec<FormatDescriptor>

Descriptors of every registered reader, in detection order.

Source

pub fn by_id(&self, id: &str) -> Option<&dyn FormatReader>

The reader with this format id, if registered.

Source

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.

Source

pub fn detect_input( &self, input: &Input, ) -> Result<(&dyn FormatReader, Detection)>

Like detect, for any Input (a local path, a buffer, a host source).

Source

pub fn open(&self, path: &Path) -> Result<(Detection, Box<dyn Dataset>)>

Detect and open.

Source

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.

Source

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).

Source

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§

Source§

impl Debug for Registry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Registry

Source§

fn default() -> Self

An empty registry, strict when the process-wide default says so (crate::assurance::default_strict: --strict, OPENREADOUT_STRICT=1).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.