Function serde_bytes::serialize
source ยท pub fn serialize<T, S>(bytes: &T, serializer: S) -> Result<S::Ok, S::Error>
Expand description
Serde serialize_with
function to serialize bytes efficiently.
This function can be used with either of the following Serde attributes:
#[serde(with = "serde_bytes")]
#[serde(serialize_with = "serde_bytes::serialize")]
use serde::Serialize;
#[derive(Serialize)]
struct Efficient<'a> {
#[serde(with = "serde_bytes")]
bytes: &'a [u8],
#[serde(with = "serde_bytes")]
byte_buf: Vec<u8>,
#[serde(with = "serde_bytes")]
byte_array: [u8; 314],
}