Skip to main content

Sidecar

Struct Sidecar 

Source
pub struct Sidecar {
    pub hello: Value,
    pub pid: u32,
    pub events: Vec<Value>,
    pub legacy_status_frames: bool,
    /* private fields */
}
Expand description

A running --stdio sidecar speaking {"type":"request","id":N,"method":{"method":"command","params":{"name","input"}}} and answering {"type":"response","status":"ok|err","id":N,"result|error":...}.

Fields§

§hello: Value§pid: u32§events: Vec<Value>

Frames that were neither hello nor the awaited response (events), oldest first. Once the list reaches twice the event limit (default 2,048, see Sidecar::set_event_limit) the oldest are trimmed back to the limit; SidecarStatus::events_dropped counts them.

§legacy_status_frames: bool

Forces the old GenRight status frames for every command when true. false does not force jobs frames: the shape then comes from the hello (see Sidecar::set_frame_shape to pin the jobs contract against a legacy hello).

Implementations§

Source§

impl Sidecar

Source

pub fn status(&self) -> SidecarStatus

Buffer counts and process resource usage, read now. No polling thread runs for this.

Source

pub fn set_event_limit(&mut self, limit: usize)

Keeps the most recent limit frames in Sidecar::events (default 2,048). Frames beyond the new limit are trimmed now, and the list is trimmed again once it reaches twice the limit.

Source

pub fn set_stderr_limit(&mut self, bytes: usize)

Keeps the last bytes of engine stderr in memory (default 256 KiB).

Source

pub fn stderr_tail(&self) -> String

Source

pub fn raw(&mut self, frame: Value, timeout: Duration) -> Result<Value>

Send an arbitrary frame and return the response with the same id.

Source

pub fn command( &mut self, name: &str, input: Value, timeout: Duration, ) -> Result<Value>

A command. Default is the rightkit-job-queue contract: {type:"request", id, method: name, params: input} answered by {type:"response", id, ok, result | error:{code,message}}. With legacy_status_frames the old GenRight shape is used (method:{method:"command", params:{name,input}}, answered with status: ok|err). The shape a hello announces is used when nothing is set; see Sidecar::resolve_shape.

Source

pub fn command_with( &mut self, name: &str, input: Value, timeout: Duration, legacy_status_frames: Option<bool>, ) -> Result<Value>

Source

pub fn set_frame_shape(&mut self, legacy: Option<bool>)

Pins the frame shape for every command on this sidecar: Some(true) the legacy GenRight frames, Some(false) the rightkit-job-queue contract, None clears the pin. A per-command Option still wins over the pin.

Source

pub fn shutdown(&mut self)

Source

pub fn close(&mut self) -> Option<i32>

Close stdin, give the engine a moment to exit, then kill the owned tree. Returns the exit code if it exited on its own.

Trait Implementations§

Source§

impl Drop for Sidecar

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

Source§

type Output = T

Should always be Self
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.