pub struct View {
pub kind: &'static str,
pub host: String,
pub data: Value,
pub human: String,
pub hints: Option<Value>,
pub pre_rendered: bool,
}Expand description
A rendered capability result: the JSON payload plus its human form.
Every capability handler returns one of these (wrapped in Result); the
shared render turns it into stdout/stderr output and an exit code. The
hints and pre_rendered fields are optional features that individual
capabilities opt into (network never sets them; services uses
pre_rendered for its streaming logs action).
Fields§
§kind: &'static strEnvelope kind discriminant (e.g. "ServiceList").
host: StringResolved target host the result pertains to.
data: ValueThe --json envelope data payload.
human: StringThe plain-text rendering printed when --json is absent.
hints: Option<Value>Optional envelope hints block (next-step suggestions).
pre_rendered: boolWhen set, the handler already wrote its own output (e.g. a streamed
log tail); render prints nothing and returns success.
Implementations§
Source§impl View
impl View
Sourcepub fn new(kind: &'static str, host: String, data: Value, human: String) -> Self
pub fn new(kind: &'static str, host: String, data: Value, human: String) -> Self
A bare view: no hints, not pre-rendered. The common case.
Sourcepub fn with_hints(self, hints: Value) -> Self
pub fn with_hints(self, hints: Value) -> Self
Attach an envelope hints block.
Sourcepub fn with_hints_opt(self, hints: Option<Value>) -> Self
pub fn with_hints_opt(self, hints: Option<Value>) -> Self
Attach an already-optional hints block (pass-through for callers that
compute Option<Value> and want to set it without unwrapping).
Sourcepub fn pre_rendered(self) -> Self
pub fn pre_rendered(self) -> Self
Mark this view as already written to stdout by the handler (e.g. a
streamed log tail); render will print nothing for it.