Struct serde_at::Bytes [−][src]
pub struct Bytes<'a>(pub &'a [u8]);
Expand description
Wrapper type to allow serializing a byte slice as bytes, rather than as a sequence (array)
Example:
use heapless::String; use serde_at::{to_string, Bytes, SerializeOptions}; use serde_derive::Serialize; #[derive(Clone, PartialEq, Serialize)] pub struct WithBytes<'a> { s: Bytes<'a>, }; let slice = b"Some bytes"; let b = WithBytes { s: Bytes(&slice[..]), }; let s: String<32> = to_string( &b, String::<32>::from("+CMD"), SerializeOptions::default(), ) .unwrap(); assert_eq!(s, String::<32>::from("AT+CMD=Some bytes\r\n"));