pub enum Ref<T> {
Reference(String),
Embedded(T),
}Expand description
An object property’s value: EXACTLY ONE of a reference to a named resource
(its canonical URI) or an embedded node (the value itself, carried inline —
derived identity, no $id). The typed twin of the wire form’s
{"$ref": uri} vs embedded-node distinction; the choice between the arms
is authorial and hash-relevant, so it is explicit here, never inferred.
Variants§
Reference(String)
A reference to a named resource by its canonical URI.
Embedded(T)
An embedded value, carried inline.
Implementations§
Source§impl<T> Ref<T>
impl<T> Ref<T>
Sourcepub fn to(uri: impl Into<String>) -> Self
pub fn to(uri: impl Into<String>) -> Self
A reference to a named resource by its canonical URI.
Sourcepub fn to_resource(target: &impl KanonakResource) -> Result<Self, CodecError>
pub fn to_resource(target: &impl KanonakResource) -> Result<Self, CodecError>
A reference to a named resource by the instance itself — resolved
through the target’s envelope id. The target must already carry its
identity; an embedded (id-less) value cannot be referenced.
Sourcepub fn embed_named(value: T, name: impl Into<String>) -> Selfwhere
T: KanonakResource,
pub fn embed_named(value: T, name: impl Into<String>) -> Selfwhere
T: KanonakResource,
An embedded value with its authored dict-key name (hash-relevant).
Sourcepub fn is_reference(&self) -> bool
pub fn is_reference(&self) -> bool
True when this is the reference arm.