[−][src]Macro macros::try_cbor
try_cbor!() { /* proc-macro */ }
Transform a block of CBOR encoding calls by adding error checking. All lines must terminate with ;
try_cbor!({ let encoder = COAP_CONTEXT.encoder("COAP_CONTEXT", "_map"); cbor_encode_text_string( encoder, COAP_CONTEXT.key_to_cstr(key_with_opt_null), COAP_CONTEXT.cstr_len(key_with_opt_null)); cbor_encode_int(encoder, value); })
expands to:
unsafe { let encoder = COAP_CONTEXT.encoder("COAP_CONTEXT", "_map"); let res = tinycbor::cbor_encode_text_string(encoder, COAP_CONTEXT.key_to_cstr(key_with_opt_null), COAP_CONTEXT.cstr_len(key_with_opt_null)); COAP_CONTEXT.check_result(res); let res = tinycbor::cbor_encode_int(encoder, value); COAP_CONTEXT.check_result(res); }