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, Cn>(
&self,
connection: &Cn
) -> Result<Option<<Col as Collection>::PrimaryKey>, Error>where
Col: NamedCollection<PrimaryKey = Id>,
Cn: Connection,
pub fn id<Col, Cn>(
&self,
connection: &Cn
) -> Result<Option<<Col as Collection>::PrimaryKey>, Error>where
Col: NamedCollection<PrimaryKey = Id>,
Cn: Connection,
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, Cn>(
&self,
connection: &Cn
) -> Result<Option<<Col as Collection>::PrimaryKey>, Error>where
Col: NamedCollection<PrimaryKey = Id>,
Cn: AsyncConnection,
pub async fn id_async<Col, Cn>(
&self,
connection: &Cn
) -> Result<Option<<Col as Collection>::PrimaryKey>, Error>where
Col: NamedCollection<PrimaryKey = Id>,
Cn: AsyncConnection,
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 for NamedReference<'a, Id>where
Id: Clone,
impl<'a, Id> Clone for NamedReference<'a, Id>where
Id: Clone,
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 for NamedReference<'a, Id>where
Id: Debug,
impl<'a, Id> Debug for NamedReference<'a, Id>where
Id: Debug,
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<NamedReference<'a, Id>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<NamedReference<'a, Id>, <__D as Deserializer<'de>>::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>) -> NamedReference<'a, Id>
fn from(doc: &'b BorrowedDocument<'b>) -> NamedReference<'a, Id>
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§fn from(name: &'a String) -> NamedReference<'a, Id>
fn from(name: &'a String) -> NamedReference<'a, Id>
Converts to this type from the input type.
source§impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
source§fn from(name: &'a str) -> NamedReference<'a, Id>
fn from(name: &'a str) -> NamedReference<'a, Id>
Converts to this type from the input type.
source§impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
source§fn from(id: DocumentId) -> NamedReference<'a, Id>
fn from(id: DocumentId) -> NamedReference<'a, Id>
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§fn from(name: String) -> NamedReference<'a, Id>
fn from(name: String) -> NamedReference<'a, Id>
Converts to this type from the input type.
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 for NamedReference<'a, Id>where
Id: PartialEq,
impl<'a, Id> PartialEq for NamedReference<'a, Id>where
Id: PartialEq,
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§fn 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
source§impl<'a, 'c, C> TryFrom<&'c CollectionDocument<C>> for NamedReference<'a, <C as Collection>::PrimaryKey>where
C: SerializedCollection,
impl<'a, 'c, C> TryFrom<&'c CollectionDocument<C>> for NamedReference<'a, <C as Collection>::PrimaryKey>where
C: SerializedCollection,
source§fn try_from(
doc: &'c CollectionDocument<C>
) -> Result<NamedReference<'a, <C as Collection>::PrimaryKey>, Error>
fn try_from( doc: &'c CollectionDocument<C> ) -> Result<NamedReference<'a, <C as Collection>::PrimaryKey>, Error>
Performs the conversion.
impl<'a, Id> Eq for NamedReference<'a, Id>where
Id: Eq,
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.