Function serde_bytes::serialize
[−]
[src]
pub fn serialize<T, S>(bytes: &T, serializer: S) -> Result<S::Ok, S::Error> where T: AsRef<[u8]>, 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")]
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_bytes; #[derive(Serialize)] struct Efficient<'a> { #[serde(with = "serde_bytes")] bytes: &'a [u8], #[serde(with = "serde_bytes")] byte_buf: Vec<u8>, }