[][src]Crate macros

Mynewt Macros for calling Mynewt APIs . Import this crate into a source code crate and check the expanded macros using:

clear ; cargo rustc -- -Z unstable-options --pretty expanded | head -20

Macros

init_strn

Initialise a null-terminated bytestring Strn that's suitable for passing to Mynewt APIs init_strn!("network") expands to Strn{ rep: ByteStr(b"network\0") } Used like this:

out

Given a static mutable variable, return an unsafe mutable pointer that's suitable for passing to Mynewt APIs for writing output. out!(NETWORK_TASK) expands to unsafe { &mut NETWORK_TASK }

strn

Create a Strn containing a null-terminated byte string that's suitable for passing to Mynewt APIs. strn!("network") expands to &Strn::new( b"network\0" ). strn!(()) expands to &Strn::new( b"\0" ). For macro calls like strn!( stringify!( value ) ), return &Strn::new( b"value\0" ). For complex macro calls like strn!( $crate::parse!(@ json device_id) ), return the parameter as is.

try_cbor

Transform a block of CBOR encoding calls by adding error checking. All lines must terminate with ;

Attribute Macros

infer_type

Given a Rust function definition, infer the placeholder types in the function

safe_wrap

Given an extern "C" block of function declarations, generate the safe wrapper for the function