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:
- Type-safe extension construction via
Extension::typed - Automatic schema generation via
ExtensionInfo::schema - Automatic key assignment via
ExtensionInfo::ID
§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§
Required Methods§
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.