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§
Sourcefn probe(&self, bytes: &[u8]) -> Option<Result<ProbeReport, ExtensionError>>
fn probe(&self, bytes: &[u8]) -> Option<Result<ProbeReport, ExtensionError>>
What bytes are, or None when they are not this provider’s.
§Errors
If bytes that look like this provider’s format cannot be read.
Sourcefn open(
&self,
bytes: Arc<[u8]>,
source: &ProviderSource,
resolver: &dyn ResourceResolver,
) -> Result<Box<dyn VisualSource>, ExtensionError>
fn open( &self, bytes: Arc<[u8]>, source: &ProviderSource, resolver: &dyn ResourceResolver, ) -> Result<Box<dyn VisualSource>, ExtensionError>
Opens bytes as the project’s source, applying its settings. Open runs the same
signature checks as Self::probe, so callers need not probe first.
§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".