surrealcs_kernel/messages/serialization/
traits.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Definitions of serialization traits for messages.

pub trait IntoVecBytes: Sized {
	fn to_be_bytes(a: Self) -> Vec<u8>;
}

impl IntoVecBytes for u16 {
	fn to_be_bytes(a: u16) -> Vec<u8> {
		a.to_be_bytes().to_vec()
	}
}

impl IntoVecBytes for usize {
	fn to_be_bytes(a: usize) -> Vec<u8> {
		a.to_be_bytes().to_vec()
	}
}