#[non_exhaustive]pub struct PaymentRequired {
pub x402_version: Version2,
pub error: Option<CompactString>,
pub resource: ResourceInfo,
pub accepts: Vec<PaymentRequirements>,
pub extensions: Extensions,
}Expand description
Body of an HTTP 402 Payment Required response.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.x402_version: Version2Protocol version (always 2).
error: Option<CompactString>Optional error message describing why the request was rejected.
resource: ResourceInfoResource metadata.
accepts: Vec<PaymentRequirements>Accepted payment terms.
extensions: ExtensionsOptional extension block.
Implementations§
Source§impl PaymentRequired
impl PaymentRequired
Sourcepub fn new(resource: ResourceInfo) -> Self
pub fn new(resource: ResourceInfo) -> Self
Constructs a 402 body with the resource and an empty accepts list.
Sourcepub fn with_accepts(self, accepts: Vec<PaymentRequirements>) -> Self
pub fn with_accepts(self, accepts: Vec<PaymentRequirements>) -> Self
Replaces the accepted payment requirements list.
Sourcepub fn add_accept(self, accept: PaymentRequirements) -> Self
pub fn add_accept(self, accept: PaymentRequirements) -> Self
Appends a single payment requirement.
Sourcepub fn with_error(self, error: impl Into<CompactString>) -> Self
pub fn with_error(self, error: impl Into<CompactString>) -> Self
Attaches a human-readable error message.
Sourcepub fn with_extensions(self, extensions: Extensions) -> Self
pub fn with_extensions(self, extensions: Extensions) -> Self
Replaces the extensions block.
Trait Implementations§
Source§impl Clone for PaymentRequired
impl Clone for PaymentRequired
Source§fn clone(&self) -> PaymentRequired
fn clone(&self) -> PaymentRequired
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PaymentRequired
impl Debug for PaymentRequired
Source§impl<'de> Deserialize<'de> for PaymentRequired
impl<'de> Deserialize<'de> for PaymentRequired
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
Source§impl PartialEq for PaymentRequired
impl PartialEq for PaymentRequired
Source§impl Serialize for PaymentRequired
impl Serialize for PaymentRequired
impl StructuralPartialEq for PaymentRequired
Auto Trait Implementations§
impl Freeze for PaymentRequired
impl RefUnwindSafe for PaymentRequired
impl Send for PaymentRequired
impl Sync for PaymentRequired
impl Unpin for PaymentRequired
impl UnsafeUnpin for PaymentRequired
impl UnwindSafe for PaymentRequired
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