pub enum X402Version {
V1(X402V1),
V2(X402V2),
}Expand description
Represents the X402 protocol version, either v1 or v2.
use serde::{Serialize, Deserialize};
use x402_core::types::{X402Version, X402V1, X402V2};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Example {
x402_version: X402Version,
// other fields...
}
let example_v1: Example = serde_json::from_value(serde_json::json!({
"x402Version": 1,
// other fields...
})).unwrap();
assert!(example_v1.x402_version.as_v1().is_some());
let json_v1 = serde_json::to_value(&example_v1).unwrap();
assert_eq!(json_v1.get("x402Version").unwrap(), &serde_json::json!(1));
let example_v2: Example = serde_json::from_value(serde_json::json!({
"x402Version": 2,
// other fields...
})).unwrap();
assert!(example_v2.x402_version.as_v2().is_some());
let json_v2 = serde_json::to_value(&example_v2).unwrap();
assert_eq!(json_v2.get("x402Version").unwrap(), &serde_json::json!(2));Variants§
V1(X402V1)
Version 1 of the X402 protocol: "x402Version": 1.
V2(X402V2)
Version 2 of the X402 protocol. "x402Version": 2.
Implementations§
Trait Implementations§
Source§impl Clone for X402Version
impl Clone for X402Version
Source§fn clone(&self) -> X402Version
fn clone(&self) -> X402Version
Returns a duplicate of the value. Read more
1.0.0 · 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 X402Version
impl Debug for X402Version
Source§impl<'de> Deserialize<'de> for X402Version
impl<'de> Deserialize<'de> for X402Version
Source§fn deserialize<D>(
deserializer: D,
) -> Result<X402Version, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<X402Version, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for X402Version
impl Display for X402Version
Source§impl Hash for X402Version
impl Hash for X402Version
Source§impl PartialEq for X402Version
impl PartialEq for X402Version
Source§impl Serialize for X402Version
impl Serialize for X402Version
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,
Serialize this value into the given Serde serializer. Read more
impl Eq for X402Version
impl StructuralPartialEq for X402Version
Auto Trait Implementations§
impl Freeze for X402Version
impl RefUnwindSafe for X402Version
impl Send for X402Version
impl Sync for X402Version
impl Unpin for X402Version
impl UnwindSafe for X402Version
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.