Enum oas_common::reference::Reference
source · [−]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(Record<T>)
Implementations
sourceimpl<T: TypedValue> Reference<T>
impl<T: TypedValue> Reference<T>
pub fn guid(&self) -> &str
sourcepub fn record_mut(&mut self) -> Option<&mut Record<T>>
pub fn record_mut(&mut self) -> Option<&mut Record<T>>
Get a mutable reference to the loaded record if the reference is resolved.
sourcepub fn into_record(self) -> Option<Record<T>>
pub fn into_record(self) -> Option<Record<T>>
Get the loaded record if the reference is resolved, while consuming the reference.
sourcepub fn extract_record(&mut self) -> Option<Record<T>>
pub fn extract_record(&mut self) -> Option<Record<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 force_resolve<R: Resolver>(
&mut self,
resolver: &R
) -> Result<(), ResolveError>
pub async fn force_resolve<R: Resolver>(
&mut self,
resolver: &R
) -> Result<(), ResolveError>
Resolve the record, even if the reference is already in the resolved state.
sourcepub async fn into_resolved<R: Resolver>(
self,
resolver: &R
) -> Result<Self, ResolveError>
pub async fn into_resolved<R: Resolver>(
self,
resolver: &R
) -> Result<Self, ResolveError>
Resolve the record while consuming self, and return a new reference in the resolved state.
sourcepub fn set_resolved(&mut self, record: Record<T>)
pub fn set_resolved(&mut self, record: Record<T>)
Set the record to the resolved state while passing in the target record.
Trait Implementations
sourceimpl<'de, T: Clone> Deserialize<'de> for Reference<T>where
T: Deserialize<'de>,
impl<'de, T: Clone> Deserialize<'de> for Reference<T>where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: TypedValue> From<ResolveError> for Reference<T>
impl<T: TypedValue> From<ResolveError> for Reference<T>
sourcefn from(err: ResolveError) -> Self
fn from(err: ResolveError) -> Self
Converts to this type from the input type.
sourceimpl<T: Clone + JsonSchema> JsonSchema for Reference<T>
impl<T: Clone + JsonSchema> JsonSchema for Reference<T>
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 moreAuto 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
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be
Self