pub struct File { /* private fields */ }Implementations§
Source§impl File
impl File
pub fn branch(&self) -> &Branch
pub async fn parent(&self) -> Result<Directory>
Sourcepub fn progress(&self) -> impl Future<Output = Result<u64>> + 'static
pub fn progress(&self) -> impl Future<Output = Result<u64>> + 'static
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.
Sourcepub async fn read(&mut self, buffer: &mut [u8]) -> Result<usize>
pub async fn read(&mut self, buffer: &mut [u8]) -> Result<usize>
Reads data from this file. Returns the number of bytes actually read.
pub async fn read_all(&mut self, buffer: &mut [u8]) -> Result<usize>
Sourcepub async fn read_to_end(&mut self) -> Result<Vec<u8>>
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.
Sourcepub async fn write(&mut self, buffer: &[u8]) -> Result<usize>
pub async fn write(&mut self, buffer: &[u8]) -> Result<usize>
Writes buffer into this file. Returns the number of bytes actually written.
pub async fn write_all(&mut self, buffer: &[u8]) -> Result<()>
Sourcepub async fn flush(&mut self) -> Result<()>
pub async fn flush(&mut self) -> Result<()>
Atomically saves any pending modifications and updates the version vectors of this file and all its ancestors.
Sourcepub async fn copy_to_writer<W: AsyncWrite + Unpin>(
&mut self,
dst: &mut W,
) -> Result<()>
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)
Sourcepub async fn fork(&mut self, dst_branch: Branch) -> Result<()>
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.
pub async fn version_vector(&self) -> Result<VersionVector>
Trait Implementations§
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> 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
§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