mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-10-14 12:48:29 -04:00
* operation receive + compare * cleanup + deduplication * operation receive + compare * cleanup + deduplication * sync route + operation grouping * tag assign sync * proper relation support in sync debug page * migration * separate core-sync + utils crates * separate p2p event loop from manager * cleanup library handling * clippy * feature gate sync messages properly * make migration not add required field
24 lines
535 B
Rust
24 lines
535 B
Rust
use uuid::Uuid;
|
|
|
|
/// Combines an iterator of `T` and an iterator of `Option<T>`,
|
|
/// removing any `None` values in the process
|
|
pub fn chain_optional_iter<T>(
|
|
required: impl IntoIterator<Item = T>,
|
|
optional: impl IntoIterator<Item = Option<T>>,
|
|
) -> Vec<T> {
|
|
required
|
|
.into_iter()
|
|
.map(Some)
|
|
.chain(optional)
|
|
.flatten()
|
|
.collect()
|
|
}
|
|
|
|
pub fn uuid_to_bytes(uuid: Uuid) -> Vec<u8> {
|
|
uuid.as_bytes().to_vec()
|
|
}
|
|
|
|
pub fn from_bytes_to_uuid(bytes: &[u8]) -> Uuid {
|
|
Uuid::from_slice(bytes).expect("corrupted uuid in database")
|
|
}
|