pub struct CompositeKey<A: KeyDomain, B: KeyDomain, const SEP: char = ':'> { /* private fields */ }Expand description
A typed composite of two domain keys, separated by SEP (default ':').
See the module-level docs for usage examples.
Implementations§
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> CompositeKey<A, B, SEP>
Sourcepub fn new(first: Key<A>, second: Key<B>) -> Self
pub fn new(first: Key<A>, second: Key<B>) -> Self
Create a CompositeKey from two typed component keys.
§Panics (debug only)
Panics in debug builds if first.as_str() contains the separator SEP.
In release builds the check is elided; callers are responsible for ensuring
the first component does not contain the separator (see module docs).
Trait Implementations§
Source§impl<'r, DB, A, B, const SEP: char> Decode<'r, DB> for CompositeKey<A, B, SEP>
impl<'r, DB, A, B, const SEP: char> Decode<'r, DB> for CompositeKey<A, B, SEP>
Source§impl<'de, A: KeyDomain, B: KeyDomain, const SEP: char> Deserialize<'de> for CompositeKey<A, B, SEP>
Available on crate feature serde only.
impl<'de, A: KeyDomain, B: KeyDomain, const SEP: char> Deserialize<'de> for CompositeKey<A, B, SEP>
serde only.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>,
Source§impl<'q, DB, A, B, const SEP: char> Encode<'q, DB> for CompositeKey<A, B, SEP>
impl<'q, DB, A, B, const SEP: char> Encode<'q, DB> for CompositeKey<A, B, SEP>
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
fn size_hint(&self) -> usize
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> FromStr for CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> FromStr for CompositeKey<A, B, SEP>
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a composite key from a string by splitting on the first occurrence
of SEP.
§Errors
CompositeKeyParseError::MissingSeparatorifSEPis not found.CompositeKeyParseError::InvalidFirstif the first segment is not a validKey<A>.CompositeKeyParseError::InvalidSecondif the second segment is not a validKey<B>.
Source§type Err = CompositeKeyParseError
type Err = CompositeKeyParseError
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> Hash for CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> Hash for CompositeKey<A, B, SEP>
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> Ord for CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> Ord for CompositeKey<A, B, SEP>
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Lexicographic ordering: compare first components, then second.
§Note on ordering consistency
This ordering compares the two Key fields independently and may differ from
the lexicographic order of the to_string() representation. For example,
when SEP = ':' (ASCII 58), a first component ending with a digit (ASCII 48–57)
sorts differently field-by-field than it does by the serialised string, because
'0'–'9' are strictly less than ':' in ASCII.
If you need ordering that is consistent with the string representation (e.g. to
match SQL ORDER BY on the stored column), sort by ck.to_string() instead.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> PartialOrd for CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> PartialOrd for CompositeKey<A, B, SEP>
Source§impl<A: KeyDomain, B: KeyDomain, const SEP: char> Serialize for CompositeKey<A, B, SEP>
Available on crate feature serde only.
impl<A: KeyDomain, B: KeyDomain, const SEP: char> Serialize for CompositeKey<A, B, SEP>
serde only.Source§impl<DB, A, B, const SEP: char> Type<DB> for CompositeKey<A, B, SEP>
impl<DB, A, B, const SEP: char> Type<DB> for CompositeKey<A, B, SEP>
impl<A: KeyDomain, B: KeyDomain, const SEP: char> Eq for CompositeKey<A, B, SEP>
Auto Trait Implementations§
impl<A, B, const SEP: char> Freeze for CompositeKey<A, B, SEP>
impl<A, B, const SEP: char> RefUnwindSafe for CompositeKey<A, B, SEP>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B, const SEP: char> Send for CompositeKey<A, B, SEP>
impl<A, B, const SEP: char> Sync for CompositeKey<A, B, SEP>
impl<A, B, const SEP: char> Unpin for CompositeKey<A, B, SEP>
impl<A, B, const SEP: char> UnsafeUnpin for CompositeKey<A, B, SEP>
impl<A, B, const SEP: char> UnwindSafe for CompositeKey<A, B, SEP>where
A: UnwindSafe,
B: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more