pub struct FileIO { /* private fields */ }Expand description
FileIO implementation, used to manipulate files in underlying storage.
FileIO wraps a dyn Storage with lazy initialization via StorageFactory.
The storage is created on first use and cached for subsequent operations.
§Note
All paths passed to FileIO must be absolute paths starting with the scheme string
appropriate for the storage backend being used.
This crate provides native support for local filesystem (file://) and
memory (memory://) storage. For extensive storage backend support (S3, GCS,
OSS, Azure, etc.), use the
iceberg-storage-opendal crate.
§Example
use iceberg::io::{FileIO, FileIOBuilder};
use iceberg::io::{LocalFsStorageFactory, MemoryStorageFactory};
use std::sync::Arc;
// Create FileIO with memory storage for testing
let file_io = FileIO::new_with_memory();
// Create FileIO with local filesystem storage
let file_io = FileIO::new_with_fs();
// Create FileIO with custom factory
let file_io = FileIOBuilder::new(Arc::new(LocalFsStorageFactory))
.with_prop("key", "value")
.build();Implementations§
Source§impl FileIO
impl FileIO
Sourcepub fn new_with_memory() -> Self
pub fn new_with_memory() -> Self
Create a new FileIO backed by in-memory storage.
This is useful for testing scenarios where persistent storage is not needed.
Sourcepub fn new_with_fs() -> Self
pub fn new_with_fs() -> Self
Create a new FileIO backed by local filesystem storage.
This is useful for local development and testing with real files.
Sourcepub fn config(&self) -> &StorageConfig
pub fn config(&self) -> &StorageConfig
Get the storage configuration.
Sourcepub async fn delete_prefix(&self, path: impl AsRef<str>) -> Result<()>
pub async fn delete_prefix(&self, path: impl AsRef<str>) -> Result<()>
Remove the path and all nested dirs and files recursively.
§Arguments
- path: It should be absolute path starting with scheme string used to construct
FileIO.
§Behavior
- If the path is a file or not exist, this function will be no-op.
- If the path is a empty directory, this function will remove the directory itself.
- If the path is a non-empty directory, this function will remove the directory and all nested files and directories.
Sourcepub async fn delete_stream(
&self,
paths: impl Stream<Item = String> + Send + 'static,
) -> Result<()>
pub async fn delete_stream( &self, paths: impl Stream<Item = String> + Send + 'static, ) -> Result<()>
Sourcepub fn new_output(&self, path: impl AsRef<str>) -> Result<OutputFile>
pub fn new_output(&self, path: impl AsRef<str>) -> Result<OutputFile>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileIO
impl !RefUnwindSafe for FileIO
impl Send for FileIO
impl Sync for FileIO
impl Unpin for FileIO
impl !UnwindSafe for FileIO
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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