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 ContextInnerImplementations§
Source§impl ResultSink<'_>
impl ResultSink<'_>
Sourcepub fn push(&self, result: PluginResult) -> Result<()>
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::InvalidContextif called outside anon_taskhandler (when the context has no result channel). - Returns
SdkError::Channelif the result channel is closed (typically because the daemon disconnected). - Returns
SdkError::Ioif the result is aFilevariant and the file cannot be read.
Sourcepub fn push_json(&self, name: &str, data: &[u8]) -> Result<()>
pub fn push_json(&self, name: &str, data: &[u8]) -> Result<()>
Push a JSON result (raw bytes that are already JSON-encoded).
Sourcepub fn push_file(&self, name: &str, path: impl AsRef<Path>) -> Result<()>
pub fn push_file(&self, name: &str, path: impl AsRef<Path>) -> Result<()>
Push a file result by path.
Sourcepub fn push_all(&self, results: Vec<PluginResult>) -> Result<()>
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.
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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].