pub struct Attribute<S: InlineEncoding> { /* private fields */ }Expand description
A typed reference to an attribute: a rooted Fragment carrying
the identity-determining facts, tagged with a phantom value-schema
marker.
The root id is cached alongside the fragment so .id() is a field
read — entity!{} codegen calls it once per attribute per fact,
and walking the fragment’s exports PATCH each time dominated the
pre-0.40 entities/union benches.
Implementations§
Source§impl<S: InlineEncoding> Attribute<S>
impl<S: InlineEncoding> Attribute<S>
Sourcepub fn inline_from<T: IntoInline<S>>(&self, v: T) -> Inline<S>
pub fn inline_from<T: IntoInline<S>>(&self, v: T) -> Inline<S>
Convert a host value into a typed Inline<S> using the Field’s schema.
This is a small convenience wrapper around the IntoInline trait and
simplifies macro expansion: af.inline_from(expr) preserves the
schema S for type inference.
Sourcepub fn encoded_from<V>(&self, v: V) -> Encoded<S>where
V: IntoEncoded<<S as InlineEncoding>::Encoding>,
<V as IntoEncoded<<S as InlineEncoding>::Encoding>>::Output: ToEncoded<S>,
pub fn encoded_from<V>(&self, v: V) -> Encoded<S>where
V: IntoEncoded<<S as InlineEncoding>::Encoding>,
<V as IntoEncoded<<S as InlineEncoding>::Encoding>>::Output: ToEncoded<S>,
Macro-side entry point: produce the Encoded<S> the
entity!{} codegen folds into a Fragment.
Dispatches via IntoEncoded, parameterised by the schema’s
Encoding — S
itself for inline schemas, the inner BlobEncoding for
Handle<T>. The resulting Output is lifted into a Encoded
via ToEncoded.
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/UnknownInline 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.
Trait Implementations§
Source§impl<S: InlineEncoding> Clone for Attribute<S>
impl<S: InlineEncoding> Clone for Attribute<S>
Source§impl<S> Describe for Attribute<S>where
S: InlineEncoding,
impl<S> Describe for Attribute<S>where
S: InlineEncoding,
impl<S: Eq + InlineEncoding> Eq for Attribute<S>
Source§impl<S: InlineEncoding> From<Fragment> for Attribute<S>
Wrap a rooted fragment as a typed attribute.
impl<S: InlineEncoding> From<Fragment> for Attribute<S>
Wrap a rooted fragment as a typed attribute.
The fragment’s root() is the attribute id; its facts (typically
metadata::iri | metadata::name together with
metadata::value_encoding) are carried through to [Describe] so the
attribute remains queryable in the metadata registry by its
originating identity attribute.
Pinning a schema’s attribute ids (so local renames don’t churn the
schema) is what the [attributes!] macro is for — declare them with
explicit hex literals there.
Source§impl<S: PartialEq + InlineEncoding> PartialEq for Attribute<S>
impl<S: PartialEq + InlineEncoding> PartialEq for Attribute<S>
impl<S: InlineEncoding> StructuralPartialEq for Attribute<S>
Auto Trait Implementations§
impl<S> !RefUnwindSafe for Attribute<S>
impl<S> !UnwindSafe for Attribute<S>
impl<S> Freeze for Attribute<S>
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>
Blanket Implementations§
impl<T> ArchiveOwner for T
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