pub struct Intent {
pub kind: String,
pub payload: Value,
}Expand description
What a work order intends to achieve.
The payload is schema-validated at construction. Whether intents come from
a registered catalogue or stay free-form is still open (ARCHITECTURE.md
§17), so the kind is a string for now and the payload is opaque CBOR.
Fields§
§kind: StringNames the kind of effect intended, e.g. patch.apply, refund.issue.
payload: ValueStructured detail, already validated against kind’s schema.
Implementations§
Source§impl Intent
impl Intent
Sourcepub fn new<T: Serialize>(
kind: impl Into<String>,
payload: &T,
) -> Result<Self, CanonicalError>
pub fn new<T: Serialize>( kind: impl Into<String>, payload: &T, ) -> Result<Self, CanonicalError>
Build an intent from any serialisable payload.
§Errors
Returns CanonicalError::Encode if the payload cannot be represented
as CBOR. This is a typed error rather than a panic: a malformed
proposal is an expected runtime condition, not a bug.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Intent
impl<'de> Deserialize<'de> for Intent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Intent
Auto Trait Implementations§
impl Freeze for Intent
impl RefUnwindSafe for Intent
impl Send for Intent
impl Sync for Intent
impl Unpin for Intent
impl UnsafeUnpin for Intent
impl UnwindSafe for Intent
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
Mutably borrows from an owned value. Read more
Source§impl<T> Canonical for T
impl<T> Canonical for T
Source§fn canonical_bytes(&self) -> Result<Vec<u8>, CanonicalError>
fn canonical_bytes(&self) -> Result<Vec<u8>, CanonicalError>
The canonical CBOR encoding of this value.