pub struct AppState {
pub client: WebA2AClient,
pub webhook_token: Option<String>,
}Expand description
Application state for Axum web applications.
This struct provides a convenient way to share the A2A client and configuration across Axum route handlers.
§Examples
use a2a_client::{WebA2AClient, AppState};
use std::sync::Arc;
let client = WebA2AClient::new_http("http://localhost:8080".to_string());
let state = Arc::new(
AppState::new(client)
.with_webhook_token("secret-token".to_string())
);Fields§
§client: WebA2AClientThe A2A client for interacting with agents
webhook_token: Option<String>Optional webhook authentication token
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(client: WebA2AClient) -> Self
pub fn new(client: WebA2AClient) -> Self
Create new application state with the given client.
§Examples
use a2a_client::{WebA2AClient, AppState};
let client = WebA2AClient::new_http("http://localhost:8080".to_string());
let state = AppState::new(client);Sourcepub fn with_webhook_token(self, token: String) -> Self
pub fn with_webhook_token(self, token: String) -> Self
Set the webhook authentication token.
§Examples
use a2a_client::{WebA2AClient, AppState};
let client = WebA2AClient::new_http("http://localhost:8080".to_string());
let state = AppState::new(client)
.with_webhook_token("secret-token".to_string());Auto Trait Implementations§
impl Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe for AppState
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