pub struct FileWriter { /* private fields */ }Expand description
A streaming write to a guest file. Chunks feed a bounded channel that backs
the client-streaming RPC, so a slow uplink applies backpressure rather than
buffering the source. The RPC result surfaces from FileWriter::finish,
and only finish commits the write: dropping (or FileWriter::aborting)
an unfinished writer cancels the RPC instead of half-closing into what the
server would treat as a completed write. The guest file state after an
abort is unspecified (the write was never confirmed).
Implementations§
Source§impl FileWriter
impl FileWriter
Sourcepub async fn write(&mut self, data: &[u8]) -> Result<(), SailError>
pub async fn write(&mut self, data: &[u8]) -> Result<(), SailError>
Write bytes to the file, splitting them into transport-sized chunks
(FILE_WRITE_CHUNK_BYTES each). This is the normal write path; use
FileWriter::write_chunk only to control message framing yourself.
Sourcepub async fn write_chunk(&mut self, data: Vec<u8>) -> Result<(), SailError>
pub async fn write_chunk(&mut self, data: Vec<u8>) -> Result<(), SailError>
Send one chunk of file data as a single transport message. Chunks must
not exceed FILE_WRITE_CHUNK_BYTES. If the RPC has already ended,
returns its result instead.
Sourcepub async fn finish(&mut self) -> Result<(), SailError>
pub async fn finish(&mut self) -> Result<(), SailError>
Finish the write and return the RPC’s result, creating an empty file when no chunks were sent.
Sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Abort the write: cancel the RPC without the clean end-of-stream the
server would commit. Idempotent; a no-op after finish. Later write
or finish calls report the abort instead of succeeding.
Sourcepub fn abort_handle(&self) -> WriteAbortHandle
pub fn abort_handle(&self) -> WriteAbortHandle
An out-of-band handle that aborts this write without borrowing the
writer, so a concurrent caller (the bindings’ abort path) can cancel a
stalled or backpressured write instead of queueing behind it.
Trait Implementations§
Source§impl Drop for FileWriter
impl Drop for FileWriter
Auto Trait Implementations§
impl Freeze for FileWriter
impl RefUnwindSafe for FileWriter
impl Send for FileWriter
impl Sync for FileWriter
impl Unpin for FileWriter
impl UnsafeUnpin for FileWriter
impl UnwindSafe for FileWriter
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request