pub struct CredentialFieldMarker {
pub variant: Option<&'static str>,
pub field: &'static str,
pub kind: CredentialKind,
pub attach_as: AttachmentSite,
pub scheme: Option<CredentialScheme>,
pub scopes: Vec<Scope>,
pub refresh_via: Option<MethodPath>,
pub revoke_via: Option<MethodPath>,
}Expand description
A single registry entry describing one #[credential(...)]-annotated
field on a credential-bearing type. The
#[derive(plexus_macros::Credentials)] macro emits a per-type free
function __plexus_credential_marker_for_<TypeIdent>() -> Vec<CredentialFieldMarker> returning these entries in stable
declaration order.
§Shape
The fields below mirror the macro’s emission contract (see
plexus-macros/src/credential.rs::emit_field_marker_initializer):
Self::variant—Some(variant_name)for enums,Nonefor structs.Self::field— the field’s identifier, e.g."session". For tuple fields, the zero-based index as a string (“0”, “1”, …).Self::kind— credential kind (Bearer,Cookie,OauthAccess, …).Self::attach_as— where the credential is attached on the wire.Self::scheme— optional attach-time prefix (e.g."Bearer ").Self::scopes— declared scopes for the credential.Self::refresh_via— optional method to refresh an expired credential.Self::revoke_via— optional method to revoke the credential.
§Aggregating into CredentialMetadata
The marker carries the credential’s static metadata as declared at the
field. The full CredentialMetadata form additionally requires
expires_at (known only at mint time) and issuer (known only at runtime
from the originating method). Self::to_metadata composes a partial
CredentialMetadata value, leaving expires_at and issuer to be
supplied by the dispatch layer.
§Consumers
AUTHZ-CRED-CORE-3(schema-build credential reflection): reads markers to project credential metadata into the IR /MethodSchema.- Backends instrumenting the registry for diagnostic purposes.
§parent_type_id (deferred)
The ticket described a parent_type_id: std::any::TypeId field for
TypeId-keyed registry lookup. The macro’s v1 emission keys the registry
by function name (__plexus_credential_marker_for_<TypeIdent>), not by
TypeId; adding parent_type_id to this struct would require either
(a) a T: 'static bound at the derive site, threading it through the
macro, or (b) materializing the TypeId in the emitted function and
stamping it onto every entry. Both are additive; neither is needed by the
current consumer set (AUTHZ-CRED-CORE-3’s schema projection works from
the function-name surface). Tracked as the follow-up note in
AUTHZ-CRED-MACRO-1-RUN-NOTES.md.
Similarly, a field_index: u16 is implicit in the slice index returned
from the registry function; callers needing index can .iter().enumerate().
§TypeId cross-compilation-unit caveat
When parent_type_id lands in a follow-up: std::any::TypeId is
documented as stable within a single compiled binary, not across
independently compiled libraries or Rust versions. The v1 use case
(one binary registering markers and reading them in the same binary) is
fine; cross-binary registry sharing would require a hashed name or a
stable type-id scheme.
Fields§
§variant: Option<&'static str>For enums: the variant name where the field lives. For structs:
None.
field: &'static strThe field’s identifier (e.g. "session"). For tuple fields, the
zero-based index rendered as a string.
kind: CredentialKindCredential kind (Bearer, Cookie, OauthAccess, …).
attach_as: AttachmentSiteWhere on the wire the credential is attached when sent on subsequent calls.
scheme: Option<CredentialScheme>Optional attach-time prefix (e.g. "Bearer " for
Authorization: Bearer <token>).
scopes: Vec<Scope>Declared scopes for the credential. Empty if not specified.
refresh_via: Option<MethodPath>Optional method-path the framework calls to refresh this credential when it expires.
revoke_via: Option<MethodPath>Optional method-path the framework calls to revoke this credential server-side.
Implementations§
Source§impl CredentialFieldMarker
impl CredentialFieldMarker
Sourcepub fn new(
variant: Option<&'static str>,
field: &'static str,
kind: CredentialKind,
attach_as: AttachmentSite,
scheme: Option<CredentialScheme>,
scopes: Vec<Scope>,
refresh_via: Option<MethodPath>,
revoke_via: Option<MethodPath>,
) -> Self
pub fn new( variant: Option<&'static str>, field: &'static str, kind: CredentialKind, attach_as: AttachmentSite, scheme: Option<CredentialScheme>, scopes: Vec<Scope>, refresh_via: Option<MethodPath>, revoke_via: Option<MethodPath>, ) -> Self
Construct a marker. Public — registry entries are user-facing metadata, not a sealed primitive. The macro emits struct-literal initializers; this constructor exists for backend code that builds markers programmatically.
Sourcepub fn to_metadata(
&self,
expires_at: Option<DateTime<Utc>>,
issuer: CredentialIssuer,
) -> CredentialMetadata
pub fn to_metadata( &self, expires_at: Option<DateTime<Utc>>, issuer: CredentialIssuer, ) -> CredentialMetadata
Compose a CredentialMetadata from this marker plus the runtime-
supplied pieces (expires_at from mint time, issuer from the
invoking method’s context).
The marker carries the static metadata declared at the field; the
dispatch layer supplies the dynamic pieces. Together they fully
reconstruct the metadata that CredentialMinter::mint would mint.
Trait Implementations§
Source§impl Clone for CredentialFieldMarker
impl Clone for CredentialFieldMarker
Source§fn clone(&self) -> CredentialFieldMarker
fn clone(&self) -> CredentialFieldMarker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more