Skip to main content

ExtensionInfo

Trait ExtensionInfo 

Source
pub trait ExtensionInfo: Clone + 'static {
    const ID: &'static str;

    // Required method
    fn schema() -> Value;
}
Expand description

Trait for typed extension info with compile-time schema generation.

Implement this trait for your extension’s info type to enable:

§Example

use serde::{Serialize, Deserialize};
use x402_core::types::{ExtensionInfo, AnyJson};
use serde_json::json;

#[derive(Debug, Clone, Serialize, Deserialize)]
struct MyInfo {
    pub value: String,
}

impl ExtensionInfo for MyInfo {
    const ID: &'static str = "my-extension";
    fn schema() -> AnyJson {
        json!({
            "type": "object",
            "properties": {
                "value": { "type": "string" }
            },
            "required": ["value"]
        })
    }
}

Required Associated Constants§

Source

const ID: &'static str

The extension identifier, used as the key in the extensions map.

Required Methods§

Source

fn schema() -> Value

Generate a JSON Schema for this extension’s info type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl ExtensionInfo for BazaarInfo

Source§

const ID: &'static str = "bazaar"

Source§

impl ExtensionInfo for SignInWithXInfo

Source§

const ID: &'static str = "sign-in-with-x"