Enum bonsaidb::core::schema::NamedReference
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§
§impl<'a, Id> NamedReference<'a, Id>where
Id: for<'k> Key<'k>,
impl<'a, Id> NamedReference<'a, Id>where Id: for<'k> Key<'k>,
pub 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.
pub 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.
pub async fn id_async<Col, Cn>(
&self,
connection: &Cn
) -> impl Future<Output = Result<Option<<Col as Collection>::PrimaryKey>, Error>>where
Col: NamedCollection<PrimaryKey = Id>,
Cn: AsyncConnection,
pub async fn id_async<Col, Cn>( &self, connection: &Cn ) -> impl Future<Output = 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§
§impl<'a, Id> Clone for NamedReference<'a, Id>where
Id: Clone,
impl<'a, Id> Clone for NamedReference<'a, Id>where Id: Clone,
§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 more§impl<'a, Id> Debug for NamedReference<'a, Id>where
Id: Debug,
impl<'a, Id> Debug for NamedReference<'a, Id>where Id: Debug,
§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>,
§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
§impl<'a, Id> From<&'a String> for NamedReference<'a, Id>
impl<'a, Id> From<&'a String> for NamedReference<'a, Id>
§fn from(name: &'a String) -> NamedReference<'a, Id>
fn from(name: &'a String) -> NamedReference<'a, Id>
Converts to this type from the input type.
§impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
impl<'a, Id> From<&'a str> for NamedReference<'a, Id>
§fn from(name: &'a str) -> NamedReference<'a, Id>
fn from(name: &'a str) -> NamedReference<'a, Id>
Converts to this type from the input type.
§impl<'a, 'b, Id> From<&'b BorrowedDocument<'b>> for NamedReference<'a, Id>
impl<'a, 'b, Id> From<&'b BorrowedDocument<'b>> for NamedReference<'a, Id>
§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.
§impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
impl<'a, Id> From<DocumentId> for NamedReference<'a, Id>
§fn from(id: DocumentId) -> NamedReference<'a, Id>
fn from(id: DocumentId) -> NamedReference<'a, Id>
Converts to this type from the input type.
§impl<'a, Id> From<String> for NamedReference<'a, Id>
impl<'a, Id> From<String> for NamedReference<'a, Id>
§fn from(name: String) -> NamedReference<'a, Id>
fn from(name: String) -> NamedReference<'a, Id>
Converts to this type from the input type.
§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,
§fn name(self) -> Result<NamedReference<'a, Id>, Error>
fn name(self) -> Result<NamedReference<'a, Id>, Error>
Returns this name as a
NamedReference
.§impl<'a, Id> Nameable<'a, Id> for NamedReference<'a, Id>
impl<'a, Id> Nameable<'a, Id> for NamedReference<'a, Id>
§fn name(self) -> Result<NamedReference<'a, Id>, Error>
fn name(self) -> Result<NamedReference<'a, Id>, Error>
Returns this name as a
NamedReference
.§impl<'a, Id> PartialEq<NamedReference<'a, Id>> for NamedReference<'a, Id>where
Id: PartialEq<Id>,
impl<'a, Id> PartialEq<NamedReference<'a, Id>> for NamedReference<'a, Id>where Id: PartialEq<Id>,
§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 ==
.§impl<'a, Id> Serialize for NamedReference<'a, Id>where
Id: Serialize,
impl<'a, Id> Serialize for NamedReference<'a, Id>where Id: Serialize,
§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
§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,
§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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.