pub struct MultiValueSet {
pub values: Vec<Vec<u8>>,
}Expand description
A set of concurrent values for MV-Register semantics.
Used with the Multi-Value merge strategy to preserve all concurrent values when conflicts occur, allowing the application to resolve them later or present all options to the user.
§Serialization Format
Values are serialized as: [4-byte count][4-byte len1][value1][4-byte len2][value2]...
§Example
use prolly::MultiValueSet;
let mv = MultiValueSet::single(b"value1".to_vec());
let mv2 = MultiValueSet::single(b"value2".to_vec());
let merged = mv.merge(&mv2);
assert_eq!(merged.values.len(), 2);Fields§
§values: Vec<Vec<u8>>All concurrent values (sorted for deterministic ordering)
Implementations§
Source§impl MultiValueSet
impl MultiValueSet
Sourcepub fn from_values(values: Vec<Vec<u8>>) -> Self
pub fn from_values(values: Vec<Vec<u8>>) -> Self
Create from multiple values.
Sourcepub fn merge(&self, other: &Self) -> Self
pub fn merge(&self, other: &Self) -> Self
Merge two sets, combining all unique values.
The resulting set contains all values from both sets, sorted lexicographically for deterministic ordering.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to bytes (length-prefixed values).
Format: [4-byte count][4-byte len][value]...
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Deserialize from bytes.
Returns None if the byte slice is malformed.
Trait Implementations§
Source§impl Clone for MultiValueSet
impl Clone for MultiValueSet
Source§fn clone(&self) -> MultiValueSet
fn clone(&self) -> MultiValueSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MultiValueSet
impl Debug for MultiValueSet
impl Eq for MultiValueSet
Source§impl PartialEq for MultiValueSet
impl PartialEq for MultiValueSet
impl StructuralPartialEq for MultiValueSet
Auto Trait Implementations§
impl Freeze for MultiValueSet
impl RefUnwindSafe for MultiValueSet
impl Send for MultiValueSet
impl Sync for MultiValueSet
impl Unpin for MultiValueSet
impl UnsafeUnpin for MultiValueSet
impl UnwindSafe for MultiValueSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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