pub struct Attr {
pub ns: Option<&'static str>,
pub key: &'static str,
pub data: OxRef<'static>,
}Expand description
An attribute attaches metadata to a container or a field
Attributes use syntax like #[facet(sensitive)] for builtins or
#[facet(orm::primary_key)] for namespaced extension attributes.
The derive macro expands attributes to macro invocations that
return Attr values with typed data.
Fields§
§ns: Option<&'static str>The namespace (e.g., Some(“orm”) in #[facet(orm::primary_key)]).
None for builtin attributes like #[facet(sensitive)].
key: &'static strThe key (e.g., “primary_key” in #[facet(orm::primary_key)])
data: OxRef<'static>Data stored by the attribute
Implementations§
Source§impl Attr
impl Attr
Sourcepub const fn new<T: Facet<'static> + Sized + Sync>(
ns: Option<&'static str>,
key: &'static str,
data: &'static T,
) -> Self
pub const fn new<T: Facet<'static> + Sized + Sync>( ns: Option<&'static str>, key: &'static str, data: &'static T, ) -> Self
Create a new attribute with typed data.
The data must be a static reference to a sized value that implements Facet.
The Sized bound is required to allow const construction.
The Sync bound is required because Attr is Sync, so the data must be
safely accessible from any thread.
Sourcepub const fn new_shape(
ns: Option<&'static str>,
key: &'static str,
shape: &'static Shape,
) -> Self
pub const fn new_shape( ns: Option<&'static str>, key: &'static str, shape: &'static Shape, ) -> Self
Create a new attribute storing a Shape reference.
This is a convenience method for shape_type variants.
Since Shape: Facet<'static>, this just delegates to new.
Sourcepub const fn is_builtin(&self) -> bool
pub const fn is_builtin(&self) -> bool
Returns true if this is a builtin attribute (no namespace).