Struct age_core::plugin::Connection

source ·
pub struct Connection<R: Read, W: Write> { /* private fields */ }
Available on crate feature plugin only.
Expand description

A connection to a plugin binary.

Implementations§

source§

impl Connection<DebugReader<ChildStdout>, DebugWriter<ChildStdin>>

source

pub fn open(binary: &Path, state_machine: &str) -> Result<Self>

Starts a plugin binary with the given state machine.

If the AGEDEBUG environment variable is set to plugin, then all messages sent to and from the plugin, as well as anything the plugin prints to its stderr, will be printed to the stderr of the parent process.

source§

impl Connection<Stdin, Stdout>

source

pub fn accept() -> Self

Initialise a connection from an age client.

source§

impl<R: Read, W: Write> Connection<R, W>

source

pub fn unidir_send<P: FnOnce(UnidirSend<'_, R, W>) -> Result<()>>( &mut self, phase_steps: P ) -> Result<()>

Runs a unidirectional phase as the controller.

source

pub fn unidir_receive<A, B, C, E, F, G, H>( &mut self, command_a: (&str, F), command_b: (&str, G), command_c: (Option<&str>, H) ) -> Result<(Result<Vec<A>, Vec<E>>, Result<Vec<B>, Vec<E>>, Option<Result<Vec<C>, Vec<E>>>)>
where F: Fn(Stanza) -> Result<A, E>, G: Fn(Stanza) -> Result<B, E>, H: Fn(Stanza) -> Result<C, E>,

Runs a unidirectional phase as the recipient.

§Arguments

command_a, command_b, and (optionally) command_c are the known commands that are expected to be received. All other received commands (including grease) will be ignored.

source

pub fn bidir_send<P: FnOnce(BidirSend<'_, R, W>) -> Result<()>>( &mut self, phase_steps: P ) -> Result<()>

Runs a bidirectional phase as the controller.

source

pub fn bidir_receive<H>(&mut self, commands: &[&str], handler: H) -> Result<()>
where H: FnMut(Stanza, Reply<'_, R, W>) -> Response,

Runs a bidirectional phase as the recipient.

Auto Trait Implementations§

§

impl<R, W> RefUnwindSafe for Connection<R, W>

§

impl<R, W> Send for Connection<R, W>
where R: Send, W: Send,

§

impl<R, W> Sync for Connection<R, W>
where R: Sync, W: Sync,

§

impl<R, W> Unpin for Connection<R, W>
where R: Unpin, W: Unpin,

§

impl<R, W> UnwindSafe for Connection<R, W>
where R: UnwindSafe, W: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V