Skip to main content

encode

Function encode 

Source
pub fn encode(
    command: Command<'_>,
    buf: &mut [u8],
) -> Result<usize, EncodeError>
Expand description

Encodes a Command into a byte buffer.

Writes the encoded frame to buf. Returns the number of bytes written on success, or an error if encoding fails.

§Example

use vesc::Command;

let mut buf = [0u8; 64];
match vesc::encode(Command::SetRpm(1500), &mut buf) {
   Ok(len) => println!("encoded: {:?}", &buf[..len]),
   _ => (),
}