pub struct StdioTransport { /* private fields */ }Expand description
The newline-framed MSP transport over a spawned host’s stdin and stdout.
Hand it the pipes from MuseChild::take_stdin and
MuseChild::take_stdout, and Connection::new gives you a raw
connection to that host. MuseClient::spawn uses this same transport.
The transport owns the host’s stdin, so close the connection before
MuseChild::close: closing it sends the host EOF, and the host exits.
Closing the host first sends no EOF, so it waits out the shutdown timeout
and then ends the host by signal.
use muse_code_sdk::connection::{Connection, StdioTransport};
use muse_code_sdk::spawn::{SpawnOptions, spawn_muse};
let mut host = spawn_muse(SpawnOptions::default())?;
let (stdin, stdout) = (host.take_stdin(), host.take_stdout());
let transport = StdioTransport::new(stdin.ok_or("no stdin")?, stdout.ok_or("no stdout")?);
let (connection, driver) = Connection::new(transport);
tokio::spawn(driver.run());
// ... the handshake, then requests ...
connection.close().await;
host.close().await?;Implementations§
Source§impl StdioTransport
impl StdioTransport
Sourcepub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
pub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
Wraps a spawned host’s stdin and stdout.
Trait Implementations§
Source§impl Debug for StdioTransport
impl Debug for StdioTransport
Source§impl DuplexTransport for StdioTransport
impl DuplexTransport for StdioTransport
Auto Trait Implementations§
impl !Freeze for StdioTransport
impl Forget for StdioTransport
impl Move for StdioTransport
impl RefUnwindSafe for StdioTransport
impl Send for StdioTransport
impl Sync for StdioTransport
impl Unpin for StdioTransport
impl UnsafeUnpin for StdioTransport
impl UnwindSafe for StdioTransport
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
Mutably borrows from an owned value. Read more