Enum bonsaidb_core::schema::NamedReference
source · pub enum NamedReference<'a, Id> {
Name(Cow<'a, str>),
Id(DocumentId),
Key(Id),
}
Expand description
A reference to a collection that has a unique name view.
Variants§
Implementations§
source§impl<'a, Id> NamedReference<'a, Id>where
Id: for<'k> Key<'k>,
impl<'a, Id> NamedReference<'a, Id>where
Id: for<'k> Key<'k>,
sourcepub fn into_owned(self) -> NamedReference<'static, Id>
pub fn into_owned(self) -> NamedReference<'static, Id>
Converts this reference to an owned reference with a 'static
lifetime.
sourcepub fn id<Col: NamedCollection<PrimaryKey = Id>, Cn: Connection>(
&self,
connection: &Cn
) -> Result<Option<Col::PrimaryKey>, Error>
pub fn id<Col: NamedCollection<PrimaryKey = Id>, Cn: Connection>( &self, connection: &Cn ) -> Result<Option<Col::PrimaryKey>, Error>
Returns this reference’s id. If the reference is a name, the
NamedCollection::ByNameView
is queried for the id.
sourcepub async fn id_async<Col: NamedCollection<PrimaryKey = Id>, Cn: AsyncConnection>(
&self,
connection: &Cn
) -> Result<Option<Col::PrimaryKey>, Error>
pub async fn id_async<Col: NamedCollection<PrimaryKey = Id>, Cn: AsyncConnection>( &self, connection: &Cn ) -> Result<Option<Col::PrimaryKey>, Error>
Returns this reference’s id. If the reference is a name, the
NamedCollection::ByNameView
is queried for the id.
Trait Implementations§
source§impl<'a, Id: Clone> Clone for NamedReference<'a, Id>
impl<'a, Id: Clone> Clone for NamedReference<'a, Id>
source§fn clone(&self) -> NamedReference<'a, Id>
fn clone(&self) -> NamedReference<'a, Id>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a, Id: Debug> Debug for NamedReference<'a, Id>
impl<'a, Id: Debug> Debug for NamedReference<'a, Id>
source§impl<'de, 'a, Id> Deserialize<'de> for NamedReference<'a, Id>where
Id: Deserialize<'de>,
impl<'de, 'a, Id> Deserialize<'de> for NamedReference<'a, Id>where
Id: Deserialize<'de>,
source§fn 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
source§impl<'a, 'b, Id> From<&'b BorrowedDocument<'b>> for NamedReference<'a, Id>
impl<'a, 'b, Id> From<&'b BorrowedDocument<'b>> for NamedReference<'a, Id>
source§fn from(doc: &'b BorrowedDocument<'b>) -> Self
fn from(doc: &'b BorrowedDocument<'b>) -> Self
Converts to this type from the input type.
source§impl<'a, Id> From<&'a String> for NamedReference<'a, Id>
impl<'a, Id> From<&'a String> for NamedReference<'a, Id>
source§impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
source§impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
source§fn from(id: DocumentId) -> Self
fn from(id: DocumentId) -> Self
Converts to this type from the input type.
source§impl<'a, Id> From<String> for NamedReference<'a, Id>
impl<'a, Id> From<String> for NamedReference<'a, Id>
source§impl<'a, Id> Nameable<'a, Id> for &'a NamedReference<'a, Id>where
Id: Clone,
impl<'a, Id> Nameable<'a, Id> for &'a NamedReference<'a, Id>where
Id: Clone,
source§fn name(self) -> Result<NamedReference<'a, Id>, Error>
fn name(self) -> Result<NamedReference<'a, Id>, Error>
Returns this name as a
NamedReference
.source§impl<'a, Id> Nameable<'a, Id> for NamedReference<'a, Id>
impl<'a, Id> Nameable<'a, Id> for NamedReference<'a, Id>
source§fn name(self) -> Result<NamedReference<'a, Id>, Error>
fn name(self) -> Result<NamedReference<'a, Id>, Error>
Returns this name as a
NamedReference
.source§impl<'a, Id: PartialEq> PartialEq for NamedReference<'a, Id>
impl<'a, Id: PartialEq> PartialEq for NamedReference<'a, Id>
source§fn eq(&self, other: &NamedReference<'a, Id>) -> bool
fn eq(&self, other: &NamedReference<'a, Id>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'a, Id> Serialize for NamedReference<'a, Id>where
Id: Serialize,
impl<'a, Id> Serialize for NamedReference<'a, Id>where
Id: Serialize,
source§impl<'a, 'c, C> TryFrom<&'c CollectionDocument<C>> for NamedReference<'a, C::PrimaryKey>where
C: SerializedCollection,
impl<'a, 'c, C> TryFrom<&'c CollectionDocument<C>> for NamedReference<'a, C::PrimaryKey>where
C: SerializedCollection,
impl<'a, Id: Eq> Eq for NamedReference<'a, Id>
impl<'a, Id> StructuralEq for NamedReference<'a, Id>
impl<'a, Id> StructuralPartialEq for NamedReference<'a, Id>
Auto Trait Implementations§
impl<'a, Id> RefUnwindSafe for NamedReference<'a, Id>where
Id: RefUnwindSafe,
impl<'a, Id> Send for NamedReference<'a, Id>where
Id: Send,
impl<'a, Id> Sync for NamedReference<'a, Id>where
Id: Sync,
impl<'a, Id> Unpin for NamedReference<'a, Id>where
Id: Unpin,
impl<'a, Id> UnwindSafe for NamedReference<'a, Id>where
Id: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more