ouisync

Struct File

Source
pub struct File { /* private fields */ }

Implementations§

Source§

impl File

Source

pub fn branch(&self) -> &Branch

Source

pub async fn parent(&self) -> Result<Directory>

Source

pub fn len(&self) -> u64

Length of this file in bytes.

Source

pub fn progress(&self) -> impl Future<Output = Result<u64>>

Sync progress of this file, that is, what part of this file (in bytes) is available locally. NOTE: The future returned from this function doesn’t borrow from self so it’s possible to drop the self before/while awaiting it. This is useful to avoid keeping the file lock while awaiting the result.

Source

pub async fn read(&mut self, buffer: &mut [u8]) -> Result<usize>

Reads data from this file. Returns the number of bytes actually read.

Source

pub async fn read_all(&mut self, buffer: &mut [u8]) -> Result<usize>

Source

pub async fn read_to_end(&mut self) -> Result<Vec<u8>>

Read all data from this file from the current seek position until the end and return then in a Vec.

Source

pub async fn write(&mut self, buffer: &[u8]) -> Result<usize>

Writes buffer into this file. Returns the number of bytes actually written.

Source

pub async fn write_all(&mut self, buffer: &[u8]) -> Result<()>

Source

pub fn seek(&mut self, pos: SeekFrom) -> u64

Seeks to an offset in the file.

Source

pub fn truncate(&mut self, len: u64) -> Result<()>

Truncates the file to the given length.

Source

pub async fn flush(&mut self) -> Result<()>

Atomically saves any pending modifications and updates the version vectors of this file and all its ancestors.

Source

pub async fn copy_to_writer<W: AsyncWrite + Unpin>( &mut self, dst: &mut W, ) -> Result<()>

Copy the entire contents of this file into the provided writer (e.g. a file on a regular filesystem)

Source

pub async fn fork(&mut self, dst_branch: Branch) -> Result<()>

Forks this file into the given branch. Ensure all its ancestor directories exist and live in the branch as well. Should be called before any mutable operation.

Source

pub async fn version_vector(&self) -> Result<VersionVector>

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 Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl !UnwindSafe 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Value for T
where T: Debug + Any + Send + 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T