pub struct Metadata {
pub tenant_id: String,
pub user_id: String,
pub project_id: String,
pub purpose: String,
pub correlation_id: String,
pub service_identity: String,
pub client_catalog_version: String,
pub scopes: Vec<String>,
pub bearer_token: String,
}Expand description
Identity and audit context for a connection.
Split deliberately into two halves, mirroring the other UDB SDKs:
- Identity — tenant, user, project, scopes, service identity — is authoritative for the connection and is never overridden per request. Letting a caller pass a different tenant per call would make the isolation boundary a client-side suggestion.
- Audit — purpose, correlation id, catalog version — is request-scoped and
may be varied per call via
Metadata::with_audit.
Fields§
§tenant_id: String§user_id: String§project_id: String§purpose: String§correlation_id: String§service_identity: String§client_catalog_version: String§scopes: Vec<String>§bearer_token: StringBearer credential. Sent as authorization: Bearer <token> when non-empty.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn new(tenant_id: impl Into<String>) -> Self
pub fn new(tenant_id: impl Into<String>) -> Self
Metadata for tenant_id, which is the minimum the broker requires.
pub fn with_project(self, project_id: impl Into<String>) -> Self
pub fn with_user(self, user_id: impl Into<String>) -> Self
pub fn with_bearer_token(self, token: impl Into<String>) -> Self
pub fn with_scopes<I, S>(self, scopes: I) -> Self
Sourcepub fn with_audit(
self,
purpose: impl Into<String>,
correlation_id: impl Into<String>,
) -> Self
pub fn with_audit( self, purpose: impl Into<String>, correlation_id: impl Into<String>, ) -> Self
Request-scoped audit fields, leaving identity untouched.
Sourcepub fn apply<T>(&self, request: &mut Request<T>) -> Result<(), Status>
pub fn apply<T>(&self, request: &mut Request<T>) -> Result<(), Status>
Apply every non-empty field to an outgoing request.
Empty values are omitted rather than sent blank: the broker treats a
present-but-empty header differently from an absent one on some paths, and
sending x-scopes: "" is not the same as claiming no scopes.
pub fn apply_to_map(&self, md: &mut MetadataMap) -> Result<(), Status>
Trait Implementations§
impl Eq for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request