Struct object_store::local::LocalFileSystem
source · pub struct LocalFileSystem { /* private fields */ }
Expand description
Local filesystem storage providing an ObjectStore
interface to files on
local disk. Can optionally be created with a directory prefix
§Path Semantics
This implementation follows the file URI scheme outlined in RFC 3986. In
particular paths are delimited by /
§Path Semantics
LocalFileSystem
will expose the path semantics of the underlying filesystem, which may
have additional restrictions beyond those enforced by Path
.
For example:
- Windows forbids certain filenames, e.g.
COM0
, - Windows forbids folders with trailing
.
- Windows forbids certain ASCII characters, e.g.
<
or|
- OS X forbids filenames containing
:
- Leading
-
are discouraged on Unix systems where they may be interpreted as CLI flags - Filesystems may have restrictions on the maximum path or path segment length
- Filesystem support for non-ASCII characters is inconsistent
Additionally some filesystems, such as NTFS, are case-insensitive, whilst others like
FAT don’t preserve case at all. Further some filesystems support non-unicode character
sequences, such as unpaired UTF-16 surrogates, and LocalFileSystem
will error on
encountering such sequences.
Finally, filenames matching the regex /.*#\d+/
, e.g. foo.parquet#123
, are not supported
by LocalFileSystem
as they are used to provide atomic writes. Such files will be ignored
for listing operations, and attempting to address such a file will error.
§Tokio Compatibility
Tokio discourages performing blocking IO on a tokio worker thread, however,
no major operating systems have stable async file APIs. Therefore if called from
a tokio context, this will use tokio::runtime::Handle::spawn_blocking
to dispatch
IO to a blocking thread pool, much like tokio::fs
does under-the-hood.
If not called from a tokio context, this will perform IO on the current thread with no additional complexity or overheads
§Symlinks
LocalFileSystem
will follow symlinks as normal, however, it is worth noting:
- Broken symlinks will be silently ignored by listing operations
- No effort is made to prevent breaking symlinks when deleting files
- Symlinks that resolve to paths outside the root will be followed
- Mutating a file through one or more symlinks will mutate the underlying file
- Deleting a path that resolves to a symlink will only delete the symlink
§Cross-Filesystem Copy
LocalFileSystem::copy
is implemented using std::fs::hard_link
, and therefore
does not support copying across filesystem boundaries.
Implementations§
source§impl LocalFileSystem
impl LocalFileSystem
sourcepub fn new_with_prefix(prefix: impl AsRef<Path>) -> Result<Self>
pub fn new_with_prefix(prefix: impl AsRef<Path>) -> Result<Self>
Create new filesystem storage with prefix
applied to all paths
Returns an error if the path does not exist
sourcepub fn path_to_filesystem(&self, location: &Path) -> Result<PathBuf>
pub fn path_to_filesystem(&self, location: &Path) -> Result<PathBuf>
Return an absolute filesystem path of the given file location
sourcepub fn with_automatic_cleanup(self, automatic_cleanup: bool) -> Self
pub fn with_automatic_cleanup(self, automatic_cleanup: bool) -> Self
Enable automatic cleanup of empty directories when deleting files
Trait Implementations§
source§impl Debug for LocalFileSystem
impl Debug for LocalFileSystem
source§impl Default for LocalFileSystem
impl Default for LocalFileSystem
source§impl Display for LocalFileSystem
impl Display for LocalFileSystem
source§impl ObjectStore for LocalFileSystem
impl ObjectStore for LocalFileSystem
source§fn put_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
payload: PutPayload,
opts: PutOptions,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
payload: PutPayload,
opts: PutOptions,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
payload
to location
with the given optionssource§fn put_multipart_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
opts: PutMultipartOpts,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_multipart_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
opts: PutMultipartOpts,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn get_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
options: GetOptions,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
options: GetOptions,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn get_range<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
range: Range<usize>,
) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_range<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
range: Range<usize>,
) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn get_ranges<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
location: &'life1 Path,
ranges: &'life2 [Range<usize>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_ranges<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
location: &'life1 Path,
ranges: &'life2 [Range<usize>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>>
fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>>
source§fn list_with_delimiter<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 Path>,
) -> Pin<Box<dyn Future<Output = Result<ListResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_with_delimiter<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 Path>,
) -> Pin<Box<dyn Future<Output = Result<ListResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn copy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn copy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn rename<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn copy_if_not_exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn copy_if_not_exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
payload: PutPayload,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
payload: PutPayload,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn put_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn head<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<ObjectMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn head<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<ObjectMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn delete_stream<'a>(
&'a self,
locations: BoxStream<'a, Result<Path>>,
) -> BoxStream<'a, Result<Path>>
fn delete_stream<'a>( &'a self, locations: BoxStream<'a, Result<Path>>, ) -> BoxStream<'a, Result<Path>>
source§fn list_with_offset(
&self,
prefix: Option<&Path>,
offset: &Path,
) -> BoxStream<'_, Result<ObjectMeta>>
fn list_with_offset( &self, prefix: Option<&Path>, offset: &Path, ) -> BoxStream<'_, Result<ObjectMeta>>
offset
Read moresource§fn rename_if_not_exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename_if_not_exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl Freeze for LocalFileSystem
impl RefUnwindSafe for LocalFileSystem
impl Send for LocalFileSystem
impl Sync for LocalFileSystem
impl Unpin for LocalFileSystem
impl UnwindSafe for LocalFileSystem
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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