Enum bonsaidb_core::connection::MaybeOwned
source · pub enum MaybeOwned<'a, TOwned, TBorrowed: ?Sized = TOwned> {
Owned(TOwned),
Borrowed(&'a TBorrowed),
}
Expand description
A value that may be owned or not. Similar to std::borrow::Cow
but does
not require Clone
.
Variants§
Trait Implementations§
source§impl<'a, TOwned, TBorrowed> Borrow<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Borrow<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
source§fn borrow(&self) -> &TBorrowed
fn borrow(&self) -> &TBorrowed
Immutably borrows from an owned value. Read more
source§impl<'a, TOwned, TBorrowed> Clone for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Clone for MaybeOwned<'a, TOwned, TBorrowed>
source§impl<'a, TOwned: Debug, TBorrowed: Debug + ?Sized> Debug for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned: Debug, TBorrowed: Debug + ?Sized> Debug for MaybeOwned<'a, TOwned, TBorrowed>
source§impl<'a, TOwned, TBorrowed> Deref for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Deref for MaybeOwned<'a, TOwned, TBorrowed>
source§impl<'a, 'k, TOwned, TBorrowed> Key<'k> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, 'k, TOwned, TBorrowed> Key<'k> for MaybeOwned<'a, TOwned, TBorrowed>
source§const CAN_OWN_BYTES: bool = TOwned::CAN_OWN_BYTES
const CAN_OWN_BYTES: bool = TOwned::CAN_OWN_BYTES
If true, this type can benefit from an owned
Vec<u8>
. This flag is
used as a hint of whether to attempt to do memcpy operations in some
decoding operations to avoid extra allocations.source§fn from_ord_bytes<'e>(bytes: ByteSource<'k, 'e>) -> Result<Self, Self::Error>
fn from_ord_bytes<'e>(bytes: ByteSource<'k, 'e>) -> Result<Self, Self::Error>
Deserialize a sequence of bytes previously encoded with
KeyEncoding::as_ord_bytes
.source§fn first_value() -> Result<Self, NextValueError>
fn first_value() -> Result<Self, NextValueError>
Return the first value in sequence for this type. Not all types
implement this.
source§fn next_value(&self) -> Result<Self, NextValueError>
fn next_value(&self) -> Result<Self, NextValueError>
Return the next value in sequence for this type. Not all types implement
this. Instead of wrapping/overflowing, None should be returned.
source§impl<'a, 'k, TOwned, TBorrowed> KeyEncoding for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, 'k, TOwned, TBorrowed> KeyEncoding for MaybeOwned<'a, TOwned, TBorrowed>
§type Error = <TOwned as KeyEncoding>::Error
type Error = <TOwned as KeyEncoding>::Error
The error type that can be produced by either serialization or
deserialization.
source§const LENGTH: Option<usize> = TBorrowed::LENGTH
const LENGTH: Option<usize> = TBorrowed::LENGTH
The size of the key, if constant. If this type doesn’t produce the same
number of bytes for each value, this should be
None
.source§fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
Describes this type by invoking functions on
visitor
describing the
key being encoded. Read moresource§impl<'a, TOwned, TBorrowed> PartialEq<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialEq<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
source§fn eq(&self, other: &TBorrowed) -> bool
fn eq(&self, other: &TBorrowed) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'a, TOwned, TBorrowed> PartialEq for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialEq for MaybeOwned<'a, TOwned, TBorrowed>
source§impl<'a, TOwned, TBorrowed> PartialOrd<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialOrd<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
source§fn partial_cmp(&self, other: &TBorrowed) -> Option<Ordering>
fn partial_cmp(&self, other: &TBorrowed) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, TOwned, TBorrowed> PartialOrd for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialOrd for MaybeOwned<'a, TOwned, TBorrowed>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreAuto Trait Implementations§
impl<'a, TOwned, TBorrowed: ?Sized> RefUnwindSafe for MaybeOwned<'a, TOwned, TBorrowed>where
TBorrowed: RefUnwindSafe,
TOwned: RefUnwindSafe,
impl<'a, TOwned, TBorrowed: ?Sized> Send for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed: ?Sized> Sync for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed: ?Sized> Unpin for MaybeOwned<'a, TOwned, TBorrowed>where
TOwned: Unpin,
impl<'a, TOwned, TBorrowed: ?Sized> UnwindSafe for MaybeOwned<'a, TOwned, TBorrowed>where
TBorrowed: RefUnwindSafe,
TOwned: 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