Skip to main content

ResultSink

Struct ResultSink 

Source
pub struct ResultSink<'a> {
    pub(super) inner: &'a ContextInner,
}
Expand description

Handle for pushing results back to the daemon during task execution.

Obtained from Context::results(). Only usable inside an on_task handler; calling push outside of one returns an error.

Fields§

§inner: &'a ContextInner

Implementations§

Source§

impl ResultSink<'_>

Source

pub fn push(&self, result: PluginResult) -> Result<()>

Push a single result back to the daemon.

Small results (below the stash threshold) travel inline on the control stream. Large byte/JSON payloads are written to the disk stash and replaced with a reference marker that the daemon pulls via the PullResult RPC (guest plugins only).

§Panics

Uses blocking_send internally. Must be called from a blocking context (e.g. spawn_blocking), not from within an async task.

§Errors
  • Returns SdkError::InvalidContext if called outside an on_task handler (when the context has no result channel).
  • Returns SdkError::Channel if the result channel is closed (typically because the daemon disconnected).
  • Returns SdkError::Io if the result is a File variant and the file cannot be read.
Source

pub fn push_json(&self, name: &str, data: &[u8]) -> Result<()>

Push a JSON result (raw bytes that are already JSON-encoded).

Source

pub fn push_bytes(&self, name: &str, data: &[u8]) -> Result<()>

Push a raw byte result.

Source

pub fn push_file(&self, name: &str, path: impl AsRef<Path>) -> Result<()>

Push a file result by path.

Source

pub fn push_all(&self, results: Vec<PluginResult>) -> Result<()>

Push a batch of results. Results are sent one at a time in order; if one fails, the remaining results are not sent and the error is returned. Results sent before the failure are not rolled back.

Source

fn classify_and_build(&self, result: PluginResult) -> Result<TaskResultMessage>

Auto Trait Implementations§

§

impl<'a> Freeze for ResultSink<'a>

§

impl<'a> !RefUnwindSafe for ResultSink<'a>

§

impl<'a> Send for ResultSink<'a>

§

impl<'a> Sync for ResultSink<'a>

§

impl<'a> Unpin for ResultSink<'a>

§

impl<'a> UnsafeUnpin for ResultSink<'a>

§

impl<'a> !UnwindSafe for ResultSink<'a>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more