30 lines
740 B
Rust
30 lines
740 B
Rust
#![allow(dead_code, unused)]
|
|
|
|
use chrono::{DateTime, Local, Utc};
|
|
use ciborium;
|
|
use cobs;
|
|
use dirs::config_dir;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct TestStruct {
|
|
pub test_int: i32,
|
|
pub test_string: String,
|
|
}
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let test_var: TestStruct = TestStruct { test_int: 0, test_string: "hello\0 world".to_owned() };
|
|
let mut serialised: Vec<u8> = Vec::with_capacity(1024);
|
|
let mut framed = vec![0u8; 1024];
|
|
|
|
_ = ciborium::into_writer(&test_var, &mut serialised);
|
|
|
|
println!("cbor: {:02x?}", &serialised[..]);
|
|
|
|
let num = cobs::encode(&serialised[..], &mut framed);
|
|
|
|
println!("cobs: {:02x?}", &framed[..num]);
|
|
|
|
Ok(())
|
|
}
|