pub struct Envelope {
pub schema_version: u32,
pub command: String,
pub engine_version: String,
pub runtime: Runtime,
pub status: Status,
pub source: Source,
pub data: Option<ResultData>,
pub artifacts: Vec<Artifact>,
pub warnings: Vec<String>,
pub error: Option<Error>,
pub effective_options: BTreeMap<String, Value>,
pub continuation: Option<Value>,
}Expand description
The terminal record of a v2 command. The envelope is one of three
shapes, distinguished by status:
ok:datacarries the phase/effect/counts/verification;erroris absent;artifactslists committed (and any uncommitted) outputs.refused:errorcarries the refusal;datarecords pre-commit state.error:errorcarries the failure;dataretains the last completed phase, including committed publication state after a reporting failure.
The Rust identifier is Envelope to avoid shadowing
std::result::Result in function signatures.
Fields§
§schema_version: u32Wire schema version; equals ENVELOPE_SCHEMA_VERSION.
command: StringCommand identifier (edit apply, edit template, …).
engine_version: StringEngine crate version.
runtime: RuntimeRuntime metadata.
status: StatusTerminal status (ok | refused | error).
source: SourceSource the request bound to.
data: Option<ResultData>Result data, including the last completed phase on failures. Only the scaffold constructor leaves it absent.
artifacts: Vec<Artifact>Committed and uncommitted artifacts.
warnings: Vec<String>Non-fatal warnings collected during preparation.
error: Option<Error>Error block; present on refused and error, absent on ok.
effective_options: BTreeMap<String, Value>Effective option values (resolved flags, defaults, configuration).
continuation: Option<Value>Continuation cursor for paginated reads; None here means
exhausted.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn with_failure_data(
self,
data: ResultData,
) -> Result<Envelope, ResultDataError>
pub fn with_failure_data( self, data: ResultData, ) -> Result<Envelope, ResultDataError>
Attach validated phase/effect/counts to a failure envelope. A committed phase records known publication; earlier phases preserve the error’s commit state, including unknown. Refusals cannot report publication.
Sourcepub fn new(
command: impl Into<String>,
source: Source,
runtime: Runtime,
) -> Envelope
pub fn new( command: impl Into<String>, source: Source, runtime: Runtime, ) -> Envelope
Build a placeholder envelope with status: ok and no data; used by
tests and scaffold code. Production callers should use
Envelope::ok (with data) or Envelope::refused /
Envelope::new_error.
Sourcepub fn ok(
command: impl Into<String>,
source: Source,
data: ResultData,
runtime: Runtime,
) -> Result<Envelope, ResultDataError>
pub fn ok( command: impl Into<String>, source: Source, data: ResultData, runtime: Runtime, ) -> Result<Envelope, ResultDataError>
Build a terminal envelope with status: ok and the supplied data.
Returns ResultDataError when data pairs its phase with an
effect or predicted effect the envelope rules forbid (see
ResultData::validate), so no contradictory ok envelope can be
built.
Sourcepub fn refused(
command: impl Into<String>,
source: Source,
error: Error,
) -> Envelope
pub fn refused( command: impl Into<String>, source: Source, error: Error, ) -> Envelope
Build a terminal envelope with status: refused and a typed
refusal. No stage is assumed complete; use Self::with_failure_data
to report a known last completed phase. Refusals are not committed.
Sourcepub fn new_error(
command: impl Into<String>,
source: Source,
error: Error,
) -> Envelope
pub fn new_error( command: impl Into<String>, source: Source, error: Error, ) -> Envelope
Build a terminal envelope with status: error and a typed
failure. No stage is assumed complete; use Self::with_failure_data
to retain completed phases, including publication after reporting errors.
Sourcepub fn push_artifact(&mut self, artifact: Artifact)
pub fn push_artifact(&mut self, artifact: Artifact)
Append an artifact to the envelope.
Sourcepub fn push_warning(&mut self, warning: impl Into<String>)
pub fn push_warning(&mut self, warning: impl Into<String>)
Append a warning to the envelope.
Sourcepub fn set_effective_option(&mut self, key: impl Into<String>, value: Value)
pub fn set_effective_option(&mut self, key: impl Into<String>, value: Value)
Set an effective option.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Envelope
impl<'de> Deserialize<'de> for Envelope
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Envelope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Envelope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Envelope
Source§impl From<&Envelope> for StreamHeader
impl From<&Envelope> for StreamHeader
Source§fn from(envelope: &Envelope) -> StreamHeader
fn from(envelope: &Envelope) -> StreamHeader
Source§impl Serialize for Envelope
impl Serialize for Envelope
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Envelope
Auto Trait Implementations§
impl Forget for Envelope
impl Freeze for Envelope
impl Move for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.