pub struct File { /* private fields */ }Expand description
An open file with concurrent positioned I/O.
Reconnect replays linked fids. Open-unlinked fids are connection-local and
produce ESTALE after connection loss.
Implementations§
Source§impl File
impl File
Sourcepub async fn read_at(&self, offset: u64, len: u32) -> Result<Bytes, ZeroFsError>
pub async fn read_at(&self, offset: u64, len: u32) -> Result<Bytes, ZeroFsError>
Read up to len bytes at offset; a shorter result means EOF. Returns
bytes::Bytes: a read served by one round trip comes back with no copy.
Sourcepub async fn write_at(
&self,
offset: u64,
data: &[u8],
) -> Result<(), ZeroFsError>
pub async fn write_at( &self, offset: u64, data: &[u8], ) -> Result<(), ZeroFsError>
Write all of data at offset (any size, chunked internally); errors
on a short write.
Sourcepub async fn metadata(&self) -> Result<Metadata, ZeroFsError>
pub async fn metadata(&self) -> Result<Metadata, ZeroFsError>
Current metadata of this open file (fstat).
Sourcepub async fn set_len(&self, size: u64) -> Result<(), ZeroFsError>
pub async fn set_len(&self, size: u64) -> Result<(), ZeroFsError>
Truncate or extend to size bytes.
Sourcepub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>
pub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>
Apply metadata changes through this handle.
Sourcepub async fn sync_all(&self) -> Result<(), ZeroFsError>
pub async fn sync_all(&self) -> Result<(), ZeroFsError>
Flush data and metadata to durable (S3-backed) storage.
Success verifies durability of earlier acknowledged writes on this
handle. Broken lineage returns ZeroFsError::Stale.
Sourcepub async fn sync_data(&self) -> Result<(), ZeroFsError>
pub async fn sync_data(&self) -> Result<(), ZeroFsError>
Flush file data to durable storage. ZeroFS currently uses the same full
durability barrier as Self::sync_all. Broken write lineage returns
ZeroFsError::Stale.
Sourcepub async fn close(&self)
pub async fn close(&self)
Marks the handle closed. Drop schedules its fid for release. This call is idempotent and non-blocking.
Sourcepub fn cursor(self: &Arc<File>) -> FileCursor
pub fn cursor(self: &Arc<File>) -> FileCursor
An independent AsyncRead + AsyncWrite + AsyncSeek cursor over this
file, starting at offset 0. Multiple cursors over one File are safe:
each carries its own position and the underlying I/O is positioned.
Rust-only sugar (tokio-io feature); never crosses FFI.