Skip to main content

View

Struct View 

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

Envelope kind discriminant (e.g. "ServiceList").

§host: String

Resolved target host the result pertains to.

§data: Value

The --json envelope data payload.

§human: String

The plain-text rendering printed when --json is absent.

§hints: Option<Value>

Optional envelope hints block (next-step suggestions).

§pre_rendered: bool

When set, the handler already wrote its own output (e.g. a streamed log tail); render prints nothing and returns success.

Implementations§

Source§

impl View

Source

pub fn new(kind: &'static str, host: String, data: Value, human: String) -> Self

A bare view: no hints, not pre-rendered. The common case.

Source

pub fn with_hints(self, hints: Value) -> Self

Attach an envelope hints block.

Source

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).

Source

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.

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

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, 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.