1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#[cfg(wasm)]
pub type DartAbi = wasm_bindgen::JsValue;
#[cfg(not(wasm))]
pub type DartAbi = allo_isolate::ffi::DartCObject;
#[cfg(wasm)]
pub trait IntoDart {
fn into_dart(self) -> DartAbi;
}
#[cfg(not(wasm))]
pub use allo_isolate::IntoDart;
#[cfg(wasm)]
pub type MessagePort = web::PortLike;
#[cfg(not(wasm))]
pub type MessagePort = i64;
#[cfg(wasm)]
pub mod web;
#[cfg(wasm)]
pub use web::*;
#[cfg(not(wasm))]
pub type Channel = allo_isolate::Isolate;
#[cfg(not(wasm))]
pub mod io;
#[cfg(not(wasm))]
pub use io::*;
#[cfg(feature = "uuid")]
const UUID_SIZE_IN_BYTES: usize = 16;
#[cfg(feature = "uuid")]
#[inline]
pub fn wire2api_uuid_ref(id: &[u8]) -> uuid::Uuid {
uuid::Uuid::from_bytes(
*<&[u8] as std::convert::TryInto<&[u8; UUID_SIZE_IN_BYTES]>>::try_into(id)
.expect("invalid uuid slice"),
)
}
#[cfg(feature = "uuid")]
#[inline]
pub fn wire2api_uuid(id: Vec<u8>) -> uuid::Uuid {
wire2api_uuid_ref(id.as_slice())
}
#[cfg(feature = "uuid")]
#[inline]
pub fn wire2api_uuids(ids: Vec<u8>) -> Vec<uuid::Uuid> {
ids.as_slice()
.chunks(UUID_SIZE_IN_BYTES)
.map(wire2api_uuid_ref)
.collect::<Vec<uuid::Uuid>>()
}