Skip to main content

write

Function write 

Source
pub fn write<W: Write + ?Sized>(frame: &CanFrame, out: &mut W) -> Result
Expand description

Write a frame as GridConnect text into out, without allocating.

Produces exactly what format() returns (no newline). Handy for no_std targets writing into a fixed buffer, or for appending many frames to one String.

ยงErrors

Only the errors returned by out itself.

use core::fmt::Write;
use rolcb::{gridconnect, CanFrame};

let mut text = String::new();
for id in [0x1070_0285, 0x1070_1285] {
    gridconnect::write(&CanFrame::new(id, &[])?, &mut text).unwrap();
    text.push('\n');
}
assert_eq!(text, ":X10700285N;\n:X10701285N;\n");