pub struct InteractionPayload {
pub title: LocalizedText,
pub body: Option<LocalizedText>,
pub options: Vec<InteractionOption>,
pub review_entries: Vec<ReviewDiffEntry>,
pub freeform_prompt: Option<LocalizedText>,
pub metadata: Value,
}Expand description
Immutable content of an interaction (spec §15.1).
Fields§
§title: LocalizedTextTitle copy.
body: Option<LocalizedText>Body copy.
options: Vec<InteractionOption>Stored options.
review_entries: Vec<ReviewDiffEntry>Diff entries for review cards.
freeform_prompt: Option<LocalizedText>Prompt for free-form interactions.
metadata: ValueApplication metadata (rendering hints, preview hash…).
Implementations§
Source§impl InteractionPayload
impl InteractionPayload
Sourcepub fn new(title: impl Into<LocalizedText>) -> Self
pub fn new(title: impl Into<LocalizedText>) -> Self
Builds a payload with only a title.
Sourcepub fn with_body(self, body: impl Into<LocalizedText>) -> Self
pub fn with_body(self, body: impl Into<LocalizedText>) -> Self
Sets the body.
Sourcepub fn with_option(self, option: InteractionOption) -> Self
pub fn with_option(self, option: InteractionOption) -> Self
Appends an option.
Sourcepub fn with_review_entry(self, entry: ReviewDiffEntry) -> Self
pub fn with_review_entry(self, entry: ReviewDiffEntry) -> Self
Appends a review entry.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Sets metadata.
Sourcepub fn hash(&self) -> Result<Digest, HashError>
pub fn hash(&self) -> Result<Digest, HashError>
BLAKE3 over the canonical JSON of the payload. Stored on the interaction
and embedded in CommandOrigin::ConfirmedInteraction so a command can
prove which content the user confirmed.
Sourcepub fn option(&self, id: &OptionId) -> Option<&InteractionOption>
pub fn option(&self, id: &OptionId) -> Option<&InteractionOption>
Finds a stored option.
Sourcepub fn option_ids(&self) -> Vec<OptionId>
pub fn option_ids(&self) -> Vec<OptionId>
Identifiers of all options.
Sourcepub fn with_freeform_prompt(self, prompt: impl Into<LocalizedText>) -> Self
pub fn with_freeform_prompt(self, prompt: impl Into<LocalizedText>) -> Self
Sets the free-form prompt.
Sourcepub fn validate_for(
&self,
kind: InteractionKind,
) -> Result<(), InteractionSpecError>
pub fn validate_for( &self, kind: InteractionKind, ) -> Result<(), InteractionSpecError>
Checks that a card of this kind can actually be answered (I6).
A user-owned phase whose card carries no usable option is a dead end: the case blocks on an answer nobody can give. The rules are:
- option ids are unique, whatever the kind;
Booleanhas exactly two options;SingleSelect,SelectTargetandResolveValidationErrorhave at least one option;ConfirmCommandandReviewChangeshave at least one option that authorizes commands and one that declines, so refusing is always possible;ReviewChangesalso has at least one diff entry;ReauthenticateandExternalSignaturehave at least one option that authorizes commands, since their whole purpose is to carry that authority;Freeformhas a prompt and an option that requires free text;MultiSelectis refused outright: the input protocol carries one option id (InteractionResponse::option_id), so a persisted multi-select card could only ever be answered as a single select.
Trait Implementations§
Source§impl Clone for InteractionPayload
impl Clone for InteractionPayload
Source§impl Debug for InteractionPayload
impl Debug for InteractionPayload
Source§impl<'de> Deserialize<'de> for InteractionPayload
impl<'de> Deserialize<'de> for InteractionPayload
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>,
impl Eq for InteractionPayload
Source§impl PartialEq for InteractionPayload
impl PartialEq for InteractionPayload
Source§impl Serialize for InteractionPayload
impl Serialize for InteractionPayload
impl StructuralPartialEq for InteractionPayload
Auto Trait Implementations§
impl Freeze for InteractionPayload
impl RefUnwindSafe for InteractionPayload
impl Send for InteractionPayload
impl Sync for InteractionPayload
impl Unpin for InteractionPayload
impl UnsafeUnpin for InteractionPayload
impl UnwindSafe for InteractionPayload
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.