Skip to main content

ExternalFiles

Struct ExternalFiles 

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

How a file name in an array pointer becomes a path on a disk.

Implementations§

Source§

impl ExternalFiles

Source

pub fn with_root(root: impl Into<PathBuf>) -> Self

Resolve relative names against this folder.

Source

pub fn set( &mut self, name: impl Into<String>, path: impl Into<PathBuf>, ) -> &mut Self

Pin one name to a path, overriding whatever the package says.

For the packages whose HDF5 file was renamed, or moved, or never had the name the object claims - all of which happen.

Source

pub fn offer(&mut self, path: impl Into<PathBuf>) -> &mut Self

Offer a file without saying what it is called.

The difference from set is the whole reason this exists. Pinning requires knowing the name the document uses, which is exactly what a person handed a renamed .h5 does not know and should not have to find out by opening the .rels in a text editor. Offering says only “the numbers might be in here”; the search opens it and looks.

Offers are tried in the order given, so a caller who knows which is likeliest can say so by putting it first.

Source

pub fn offered(&self) -> &[PathBuf]

The files offered without a name, in order.

Source

pub fn declare_present(&mut self, name: impl Into<String>) -> &mut Self

State that a file of this name is available, without saying where.

For a store that has no filesystem, which in practice means a browser. Everything else here answers “which path”, and every candidate is filtered on the path existing - which is false for all of them when there are no paths. Without this, the search yields nothing in a browser and no array is ever read, whatever backend is plugged in: the resolution would collapse silently one layer above the thing that was supposed to do the work.

So a declared name is a candidate whose path is the name itself. It goes nowhere on disk, and it is not meant to: a backend that lives outside this process - h5wasm behind ArrayBackend, holding the bytes in its own memory - receives that name and resolves it its own way.

The bytes deliberately do not come through here. Whoever decodes the format is who should hold them, and for HDF5 in a browser that is the JavaScript side; copying nineteen megabytes into this process so that it can hand them straight back out would buy nothing.

Named rather than offered, because a caller who has the file also knows what it is called - it is a file they picked or were given. A name that matches nothing in the package still gets its turn, under Origin::Offered, in the order declared.

Source

pub fn present(&self) -> &[String]

The names declared present, in order.

Source

pub fn is_virtual(&self) -> bool

Whether any name was declared present - the shape a store takes when it has no filesystem to resolve against.

Source

pub fn candidates( &self, declared: &str, package: Option<&Path>, ) -> Vec<Candidate>

Every place worth looking for a dataset that the document says is in declared, most authoritative first.

Existence is filtered here; content is not. Whether a candidate actually holds the dataset is a question only a backend can answer, and asking it is the caller’s half of the job - see Origin for why the division matters.

package is the .epc itself when there is one on disk, which is what Origin::Companion is derived from and what is excluded from Origin::Neighbour.

Source

pub fn root(&self) -> Option<&Path>

The folder relative names resolve against.

Source

pub fn set_root(&mut self, root: impl Into<PathBuf>) -> &mut Self

Set the folder relative names resolve against.

Source

pub fn resolve(&self, name: &str) -> Result<PathBuf>

Turn the name an array pointer carries into a path that exists.

Source

pub fn destination_for(&self, name: &str) -> Result<PathBuf>

Where a file of this name would go, whether or not it is there yet.

ExternalFiles::resolve answers “where is it”, and every branch of it requires the file to exist - which is right for reading and useless for writing. This answers “where should it be written”, using the same precedence so that a file created here is found by resolve afterwards.

Errors when there is nowhere to put it: no override, not absolute, and no root. Inventing the working directory would scatter data files next to whatever the process happened to be run from.

Trait Implementations§

Source§

impl Clone for ExternalFiles

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExternalFiles

Source§

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

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

impl Default for ExternalFiles

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more