1extern crate bitfield_struct;
2
3#[macro_use]
4extern crate bitflags;
5extern crate core;
6
7mod types;
8mod api;
9mod bitrate_builder;
10mod can_message_builder;
11mod data_builder;
12
13use std::fmt;
14pub use types::*;
15pub use api::*;
16
17impl BMCanMessage {
18 pub fn payload(&self) -> &[u8] {
19 unsafe {
20 &self.payload[0..self.ctrl.rx.dlc() as usize]
21 }
22 }
23
24 pub fn sid(&self) -> u16 {
25 self.mid.sid()
26 }
27
28 pub fn eid(&self) -> u32 {
29 self.mid.eid()
30 }
31
32 fn to_bytes(&self) -> Vec<u8> {
33 let ptr = self as *const BMCanMessage as *const u8;
34 let len = std::mem::size_of::<BMCanMessage>();
35 unsafe { std::slice::from_raw_parts(ptr, len) }.to_vec()
36 }
37}
38
39impl fmt::Display for BMStatus {
40 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41 write!(f, "{:?}", self)
42 }
43}