a2a_protocol_server/call_context_peer.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Tom F. <[email protected]> (https://github.com/tomtom215)
3
4//! The connection metadata a binding hands a call: the peer's address and
5//! certificate, as request extensions and as the headers-map keys they travel
6//! under. Documented, and re-exported, at [`call_context`](crate::call_context).
7
8use std::net::SocketAddr;
9
10/// The headers-map key under which a binding records the address of the
11/// connection a call arrived on, as `ip:port`; see [`CallContext::peer_addr`](crate::call_context::CallContext::peer_addr).
12///
13/// A transport of your own that calls the
14/// [`RequestHandler`](crate::RequestHandler) directly sets it in the headers
15/// map it passes.
16pub const PEER_ADDR_KEY: &str = ":peer-addr";
17
18/// The address of the connection a request arrived on, as an HTTP request
19/// extension.
20///
21/// The SDK's servers insert it into each request before dispatching it, and
22/// the dispatchers copy it to [`CallContext::peer_addr`](crate::call_context::CallContext::peer_addr); see the
23/// [module docs](crate::call_context).
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub struct PeerAddr(pub SocketAddr);
26
27/// The headers-map key under which a binding records the client's
28/// mutual-TLS certificate, standard base64 of its DER encoding; see
29/// [`CallContext::peer_certificate`](crate::call_context::CallContext::peer_certificate).
30pub const PEER_CERTIFICATE_KEY: &str = ":peer-certificate";
31
32/// The certificate a client presented in the TLS handshake of the
33/// connection a request arrived on, DER-encoded, as an HTTP request
34/// extension; see the [module docs](crate::call_context).
35#[derive(Debug, Clone, PartialEq, Eq, Hash)]
36pub struct PeerCertificate(pub std::sync::Arc<[u8]>);