Skip to main content

LocalSink

Struct LocalSink 

Source
pub struct LocalSink { /* private fields */ }
Expand description

A local file opened for both directions, so the zoom pass reads back through the handle that wrote.

Implementations§

Source§

impl LocalSink

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn discard(&mut self)

Drop the handle and remove the file, without flushing what is staged.

What a writer that has given up wants: create truncated the path at open, so leaving quietly still leaves a zero-magic stub behind that the caller has to clean up. Nothing staged is worth writing to a file about to be unlinked.

The handle goes first because Windows refuses to remove an open file. A removal that fails — the path already gone, a directory that is not writable — is not reported: this is the cleanup path of an error that is already on its way to the caller, and a second error would only hide the first.

Source

pub fn as_source(&mut self) -> Result<SinkSource<'_>>

A read view over what has been written, for the zoom pass. Flushes first, so the view never lags the writer.

Trait Implementations§

Source§

impl ByteSink for LocalSink

Source§

fn path(&self) -> &str

Source§

fn append(&mut self, data: &[u8]) -> Result<u64>

Append, returning the offset the data landed at.
Source§

fn write_all_at(&mut self, offset: u64, data: &[u8]) -> Result<()>

Overwrite bytes already written — a reserved header field, an item count.
Source§

fn position(&self) -> u64

Bytes written so far, which is also the offset the next append lands at.
Source§

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

Source§

fn close(&mut self) -> Result<()>

Finish. Idempotent, and also called from Drop — but a Drop that fails cannot report, so the writer’s own close() is what callers use and what returns the error.
Source§

impl Debug for LocalSink

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for LocalSink

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.