Function serde_bytes::serialize [−][src]
pub fn serialize<T: ?Sized, S>(
bytes: &T,
serializer: S
) -> Result<S::Ok, S::Error> where
T: Serialize,
S: Serializer,
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>, }