Skip to main content

OwnedWriteHalf

Struct OwnedWriteHalf 

Source
pub struct OwnedWriteHalf { /* private fields */ }
Available on crate feature tokio only.
Expand description

Owned input half returned by Session::into_parts.

Bytes written here become console input for the child, exactly as if they had been typed: line-oriented programs expect \r\n, not \n.

AsyncWriteExt::flush is a no-op: writes go straight to the pipe, and there is no user-space buffer to push.

§Dropping — or shutting down — this half ends the session

Closing this half is not a polite “no more input” signal. It closes conin and requests pseudoconsole close, which sends a close event to every attached client. A child that is still running is therefore terminated with exit code 0xC000013A (STATUS_CONTROL_C_EXIT) and loses any output it had not written yet. Hold on to this half until the child has exited — or close it deliberately to end a session that ignores everything else.

AsyncWriteExt::shutdown is that deliberate close: it never blocks, it cancels a write still in flight rather than flushing it, and it makes later writes fail with io::ErrorKind::BrokenPipe; shutting down again is a no-op. Dropping this half closes the pipe the same way. One caveat: with an overlapped write in flight, the OS handle closes only once the runtime’s I/O driver has retired the cancelled operation, so the console host observes the close after the driver’s next poll — one poll, not an unbounded wait for the host to drain the pipe.

Trait Implementations§

Source§

impl AsyncWrite for OwnedWriteHalf

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more
Source§

impl Debug for OwnedWriteHalf

Deliberately opaque: nothing but the conin pipe handle lives here.

Source§

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

Formats the value using the given formatter. 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> 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 = 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.
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