pub struct Attribute<S: ValueSchema> { /* private fields */ }Expand description
A typed reference to an attribute id together with its value schema.
Implementations§
Source§impl<S: ValueSchema> Attribute<S>
impl<S: ValueSchema> Attribute<S>
Sourcepub const fn from_id_with_usage(raw: RawId, usage: AttributeUsage) -> Self
pub const fn from_id_with_usage(raw: RawId, usage: AttributeUsage) -> Self
Construct a Field from a raw 16-byte id and a fully specified usage.
Sourcepub const fn from_id(raw: RawId) -> Self
pub const fn from_id(raw: RawId) -> Self
Construct a Field from a raw 16-byte id without attaching a static name.
Prefer Attribute::from_id_with_usage when a static usage is available.
Sourcepub fn id(&self) -> Id
pub fn id(&self) -> Id
Convert to a runtime Id value. This performs the nil check and will
panic if the raw id is the nil id (all zeros).
Sourcepub fn value_from<T: ToValue<S>>(&self, v: T) -> Value<S>
pub fn value_from<T: ToValue<S>>(&self, v: T) -> Value<S>
Convert a host value into a typed Value<S> using the Field’s schema.
This is a small convenience wrapper around the ToValue trait and
simplifies macro expansion: af.value_from(expr) preserves the
schema S for type inference.
Sourcepub fn as_variable(&self, v: Variable<S>) -> Variable<S>
pub fn as_variable(&self, v: Variable<S>) -> Variable<S>
Coerce an existing variable of any schema into a variable typed with
this field’s schema. This is a convenience for macros: they can
allocate an untyped/UnknownValue variable and then annotate it with the
field’s schema using af.as_variable(raw_var).
The operation is a zero-cost conversion as variables are simply small integer indexes; the implementation uses an unsafe transmute to change the type parameter without moving the underlying data.
Sourcepub const fn with_usage(self, usage: AttributeUsage) -> Self
pub const fn with_usage(self, usage: AttributeUsage) -> Self
Attach usage metadata to an attribute.
Sourcepub fn from_name(name: &str) -> Self
pub fn from_name(name: &str) -> Self
Derive an attribute id from a dynamic name and this schema’s metadata.
The identifier is computed by hashing the field name handle produced as a
Handle<Blake3, crate::blob::schemas::longstring::LongString> together with the
schema’s crate::metadata::ConstId::ID.
The resulting 32-byte Blake3 digest uses its rightmost 16 bytes to match the
RawId layout used by Attribute::from_id.
Trait Implementations§
Source§impl<S: ValueSchema> Clone for Attribute<S>
impl<S: ValueSchema> Clone for Attribute<S>
Source§impl<S> Describe for Attribute<S>where
S: ValueSchema + ConstDescribe,
impl<S> Describe for Attribute<S>where
S: ValueSchema + ConstDescribe,
impl<S: Eq + ValueSchema> Eq for Attribute<S>
impl<S: ValueSchema> StructuralPartialEq for Attribute<S>
Auto Trait Implementations§
impl<S> Freeze for Attribute<S>
impl<S> RefUnwindSafe for Attribute<S>where
S: RefUnwindSafe,
impl<S> Send for Attribute<S>where
S: Send,
impl<S> Sync for Attribute<S>where
S: Sync,
impl<S> Unpin for Attribute<S>where
S: Unpin,
impl<S> UnsafeUnpin for Attribute<S>
impl<S> UnwindSafe for Attribute<S>where
S: UnwindSafe,
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
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
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more