pub struct Credential<T> { /* private fields */ }Expand description
A sealed credential value. The inner T is constructable only via a
CredentialMinter — itself only obtainable as a function parameter
injected by the framework into credential-issuing methods.
Activation code can:
- Construct via
minter.mint(payload, metadata)(the framework witnesses the construction) - Read metadata via
Credential::metadata(immutable reference) - Serialize via
serde_json::to_value(&cred)— this produces ONLY the sentinel{"$credential": "<id>"}; the inner value never appears.
Activation code CANNOT:
- Construct from raw bytes (no public
new/From<T>) - Mutate the inner value (no
&mutaccessor) - Read the inner value via
serde_json::to_value(the customSerializeimpl writes the sentinel, not the value) - Deserialize from raw JSON (
Deserializeis intentionally absent)
§Sealing
Credential<T>::new_sealed is pub(crate). Only CredentialMinter
inside this crate calls it. The compile-fail tests in
tests/compile_fail/credential_*.rs assert that external construction
is rejected.
Implementations§
Source§impl<T> Credential<T>
impl<T> Credential<T>
Sourcepub fn metadata(&self) -> &CredentialMetadata
pub fn metadata(&self) -> &CredentialMetadata
Immutable accessor for the metadata. There is no mutable counterpart — metadata is fixed at mint time.
Sourcepub fn id(&self) -> &CredentialId
pub fn id(&self) -> &CredentialId
The credential’s stable id (used in the wire sentinel).
Source§impl<T> Credential<T>
impl<T> Credential<T>
Sourcepub fn audit_projection(&self) -> &CredentialMetadata
pub fn audit_projection(&self) -> &CredentialMetadata
Project to the metadata for audit-record emission. Read-only; the returned reference is the metadata exactly as fixed at mint time.
Equivalent to Self::metadata, named separately to make the
audit-side projection grep-discoverable. Per
AUTHZ-CRED-S01-output §8, the audit pipeline records
credentials_issued: Vec<CredentialMetadata> — this is the projection
that produces it. The inner credential value is never included.
Trait Implementations§
Source§impl<T: Clone> Clone for Credential<T>
impl<T: Clone> Clone for Credential<T>
Source§fn clone(&self) -> Credential<T>
fn clone(&self) -> Credential<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for Credential<T>
impl<T: Debug> Debug for Credential<T>
Source§impl<T> Serialize for Credential<T>where
T: Serialize,
impl<T> Serialize for Credential<T>where
T: Serialize,
Source§fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
Emits the sentinel {"$credential": "<id>"} always.
If a dispatch-capture guard is active on the current thread, the
inner value is ALSO captured into the sidecar (keyed by id) so the
dispatch wrapper can emit it under the envelope’s _credentials
key. Application code that calls serde_json::to_value(&credential)
without a guard sees only the sentinel — the inner value never
appears in the produced JSON.