File: heapless_string_value.rs

package info (click to toggle)
rust-zvariant 5.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 844 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[test]
#[cfg(feature = "heapless")]
fn heapless_string_value() {
    use heapless::String;
    use zvariant::{LE, serialized::Context, to_bytes};

    #[macro_use]
    mod common {
        include!("common.rs");
    }

    let s = String::<32>::try_from("hello world!").unwrap();
    let ctxt = Context::new_dbus(LE, 0);
    let encoded = to_bytes(ctxt, &s).unwrap();
    assert_eq!(encoded.len(), 17);
    let decoded: String<32> = encoded.deserialize().unwrap().0;
    assert_eq!(&decoded, "hello world!");
}