Skip to main content

CredentialFieldMarker

Struct CredentialFieldMarker 

Source
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::variantSome(variant_name) for enums, None for 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 str

The field’s identifier (e.g. "session"). For tuple fields, the zero-based index rendered as a string.

§kind: CredentialKind

Credential kind (Bearer, Cookie, OauthAccess, …).

§attach_as: AttachmentSite

Where 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

Source

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.

Source

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

Source§

fn clone(&self) -> CredentialFieldMarker

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CredentialFieldMarker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more