Skip to main content

Output

Struct Output 

Source
pub struct Output {
    pub status: String,
    pub output: String,
    pub data: Option<Value>,
    pub backup_path: Option<PathBuf>,
    pub error: Option<String>,
    pub duration_ms: u64,
    pub telemetry_delta: Telemetry,
    pub artifacts: Vec<PathBuf>,
}
Expand description

Output from capability execution.

Returned by every Capability::execute call. Provides a standardized envelope across all capabilities — status distinguishes ok/error, output carries human-readable text, data holds structured JSON, and error contains the failure message when status is "error".

§Invariants

  • status is always "ok" or "error".
  • When status == "error", error is Some.
  • When status == "ok", error is None.
  • data is capability-specific structured output (may be None).
  • backup_path is set when a file was backed up before mutation.
  • artifacts lists paths of files created or modified by the capability.

§Constructors

Use Output::ok for successful executions and Output::error for failures. Do not construct Output directly — the constructors enforce the invariants above.

Fields§

§status: String

Execution status: "ok" or "error".

§output: String

Human-readable result message.

§data: Option<Value>

Capability-specific structured data (JSON). None when the capability produces no structured output.

§backup_path: Option<PathBuf>

Path to a backup file created before mutation. None when no backup was created (e.g., read-only operations, new files).

§error: Option<String>

Error message when status == "error". None when status == "ok".

§duration_ms: u64

Wall-clock execution duration in milliseconds.

§telemetry_delta: Telemetry

Telemetry delta captured around the execution (before/after).

§artifacts: Vec<PathBuf>

Paths of files created or modified by this capability execution.

Implementations§

Source§

impl Output

Source

pub fn ok(output: String) -> Self

Creates a successful output with the given human-readable message.

Sets status to "ok", error to None, and all other fields to sensible defaults. Callers should populate data, backup_path, and artifacts after construction as needed.

§Examples
use runtimo_core::capability::Output;

let out = Output::ok("Read 42 bytes".into());
assert_eq!(out.status, "ok");
assert!(out.error.is_none());
Source

pub fn error(output: String, error: String) -> Self

Creates an error output with the given human-readable message and error detail.

Sets status to "error" and error to Some(error). The output field carries a caller-facing summary; error carries the machine-parseable failure reason.

§Examples
use runtimo_core::capability::Output;

let out = Output::error("failed".into(), "file not found".into());
assert_eq!(out.status, "error");
assert_eq!(out.error.as_deref(), Some("file not found"));
Source

pub fn to_json(&self) -> Value

Serializes the output to a JSON Value.

All fields are included — this is the canonical JSON representation written to the WAL and returned to clients.

Trait Implementations§

Source§

impl Clone for Output

Source§

fn clone(&self) -> Output

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Output

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Output

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Output

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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