Skip to main content

VisualProvider

Trait VisualProvider 

Source
pub trait VisualProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn probe(&self, bytes: &[u8]) -> Option<Result<ProbeReport, ExtensionError>>;
    fn open(
        &self,
        bytes: Arc<[u8]>,
        source: &ProviderSource,
        resolver: &dyn ResourceResolver,
    ) -> Result<Box<dyn VisualSource>, ExtensionError>;
}
Expand description

Reads one family of formats.

Required Methods§

Source

fn name(&self) -> &'static str

The provider’s name, for diagnostics.

Source

fn probe(&self, bytes: &[u8]) -> Option<Result<ProbeReport, ExtensionError>>

What bytes are, or None when they are not this provider’s.

§Errors

Why bytes that look like this provider’s format cannot be read.

Source

fn open( &self, bytes: Arc<[u8]>, source: &ProviderSource, resolver: &dyn ResourceResolver, ) -> Result<Box<dyn VisualSource>, ExtensionError>

Opens bytes as the project’s source, whose settings (such as which item of a package it shows) the provider applies. Bytes that are not this provider’s, those Self::probe answers None for, are told apart here, from the same signature checks: opening never probes first, so a file is read once.

§Errors

ExtensionError::Mismatch for bytes that are not this provider’s, or why they cannot be opened.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§