pub struct DataSource { /* private fields */ }Expand description
Local-file abstraction with transparent gzip decompression.
Analogue of numpy.lib.npyio.DataSource. Wraps an optional base
directory; open(name) resolves name relative to the base (if any)
and opens the file, transparently decompressing it when the path ends
in .gz.
URL fetching, the bz2/zstd formats, and the auto-cache behavior
of NumPy’s class are not implemented — for remote sources, fetch via
the project’s safe-fetch path first, then point DataSource at the
local copy.
Implementations§
Source§impl DataSource
impl DataSource
Sourcepub fn abspath(&self, name: &str) -> FerrayResult<PathBuf>
pub fn abspath(&self, name: &str) -> FerrayResult<PathBuf>
Resolve a name (relative to base, if set) to an absolute path.
§Errors
Returns FerrayError::IoError if std::path::absolute fails to
canonicalize the path (e.g. permission errors on the parent).
Sourcepub fn exists(&self, name: &str) -> bool
pub fn exists(&self, name: &str) -> bool
Whether the named file exists relative to the base directory.
Sourcepub fn open(&self, name: &str) -> FerrayResult<DataSourceReader>
pub fn open(&self, name: &str) -> FerrayResult<DataSourceReader>
Open a file for reading.
If name ends in .gz, the returned reader transparently
decompresses on the fly.
§Errors
Returns FerrayError::IoError if the file cannot be opened.
Sourcepub fn open_path<P: AsRef<Path>>(path: P) -> FerrayResult<DataSourceReader>
pub fn open_path<P: AsRef<Path>>(path: P) -> FerrayResult<DataSourceReader>
Open an absolute path directly, bypassing the configured base.
§Errors
Returns FerrayError::IoError if the file cannot be opened.
Trait Implementations§
Source§impl Clone for DataSource
impl Clone for DataSource
Source§fn clone(&self) -> DataSource
fn clone(&self) -> DataSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more