pub enum Reference<T>where
T: Clone,{
Id(String),
Resolved(TypedRecord<T>),
}
Expand description
A reference is an enum that can be in two states: It either holds an ID to a record, or a loaded record.
Variants
Id(String)
Resolved(TypedRecord<T>)
Implementations
sourceimpl<T> Reference<T>where
T: TypedValue,
impl<T> Reference<T>where
T: TypedValue,
pub fn guid(&self) -> &str
sourcepub fn record(&self) -> Option<&TypedRecord<T>>
pub fn record(&self) -> Option<&TypedRecord<T>>
Get the loaded record if the reference is resolved.
sourcepub fn record_mut(&mut self) -> Option<&mut TypedRecord<T>>
pub fn record_mut(&mut self) -> Option<&mut TypedRecord<T>>
Get a mutable reference to the loaded record if the reference is resolved.
sourcepub fn into_record(self) -> Option<TypedRecord<T>>
pub fn into_record(self) -> Option<TypedRecord<T>>
Get the loaded record if the reference is resolved, while consuming the reference.
sourcepub fn extract_record(&mut self) -> Option<TypedRecord<T>>
pub fn extract_record(&mut self) -> Option<TypedRecord<T>>
Extract the loaded record if the reference is resolved, while converting the reference to only hold an id.
sourcepub fn resolved(&self) -> bool
pub fn resolved(&self) -> bool
Check if the reference is resolved and contains a loaded record.
sourcepub async fn resolve<R>(
&mut self,
resolver: &R
) -> impl Future<Output = Result<(), ResolveError>>where
R: Resolver,
pub async fn resolve<R>(
&mut self,
resolver: &R
) -> impl Future<Output = Result<(), ResolveError>>where
R: Resolver,
sourcepub async fn force_resolve<R>(
&mut self,
resolver: &R
) -> impl Future<Output = Result<(), ResolveError>>where
R: Resolver,
pub async fn force_resolve<R>(
&mut self,
resolver: &R
) -> impl Future<Output = Result<(), ResolveError>>where
R: Resolver,
Resolve the record, even if the reference is already in the resolved state.
sourcepub async fn into_resolved<R>(
self,
resolver: &R
) -> impl Future<Output = Result<Reference<T>, ResolveError>>where
R: Resolver,
pub async fn into_resolved<R>(
self,
resolver: &R
) -> impl Future<Output = Result<Reference<T>, ResolveError>>where
R: Resolver,
Resolve the record while consuming self, and return a new reference in the resolved state.
sourcepub fn set_resolved(&mut self, record: TypedRecord<T>)
pub fn set_resolved(&mut self, record: TypedRecord<T>)
Set the record to the resolved state while passing in the target record.
Trait Implementations
sourceimpl<'de, T> Deserialize<'de> for Reference<T>where
T: Clone + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Reference<T>where
T: Clone + Deserialize<'de>,
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Reference<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Reference<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> From<ResolveError> for Reference<T>where
T: TypedValue,
impl<T> From<ResolveError> for Reference<T>where
T: TypedValue,
sourcefn from(err: ResolveError) -> Reference<T>
fn from(err: ResolveError) -> Reference<T>
Converts to this type from the input type.
sourceimpl<T> JsonSchema for Reference<T>where
T: Clone + JsonSchema,
impl<T> JsonSchema for Reference<T>where
T: Clone + JsonSchema,
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresourceimpl<T> Serialize for Reference<T>where
T: Clone + Serialize,
impl<T> Serialize for Reference<T>where
T: Clone + Serialize,
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Reference<T>where
T: RefUnwindSafe,
impl<T> Send for Reference<T>where
T: Send,
impl<T> Sync for Reference<T>where
T: Sync,
impl<T> Unpin for Reference<T>where
T: Unpin,
impl<T> UnwindSafe for Reference<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
Converts
self
into a collection.fn mapped<U, F, A>(self, f: F) -> SmallVec<A>where
F: FnMut(T) -> U,
A: Array<Item = U>,
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be
Self