Skip to main content

File

Struct File 

Source
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

Source

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.

Source

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.

Source

pub async fn metadata(&self) -> Result<Metadata, ZeroFsError>

Current metadata of this open file (fstat).

Source

pub async fn set_len(&self, size: u64) -> Result<(), ZeroFsError>

Truncate or extend to size bytes.

Source

pub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>

Apply metadata changes through this handle.

Source

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.

Source

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.

Source

pub async fn close(&self)

Marks the handle closed. Drop schedules its fid for release. This call is idempotent and non-blocking.

Source

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.

Trait Implementations§

Source§

impl Debug for File

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for File

§

impl !RefUnwindSafe for File

§

impl !UnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnsafeUnpin for File

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> 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, 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