Skip to main content

Attribute

Struct Attribute 

Source
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>

Source

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.

Source

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.

Source

pub const fn raw(&self) -> RawId

Return the underlying raw id bytes.

Source

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).

Source

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.

Source

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.

Source

pub fn name(&self) -> Option<&str>

Returns the declared name of this attribute, if any.

Source

pub const fn with_usage(self, usage: AttributeUsage) -> Self

Attach usage metadata to an attribute.

Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + ValueSchema> Debug for Attribute<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S> Describe for Attribute<S>

Source§

fn describe<B>(&self, blobs: &mut B) -> Result<Fragment, B::PutError>
where B: BlobStore<Blake3>,

Produces a Fragment describing this item, storing any long-form content as blobs.
Source§

impl<S: Hash + ValueSchema> Hash for Attribute<S>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S: PartialEq + ValueSchema> PartialEq for Attribute<S>

Source§

fn eq(&self, other: &Attribute<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Eq + ValueSchema> Eq for Attribute<S>

Source§

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V