Skip to content

Commit d2b284e

Browse files
committed
Updated doc
1 parent f0db956 commit d2b284e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rust/mynewt/src/encoding/coap_context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,27 @@ const COAP_KEY_SIZE: usize = 32;
2525
/// Size of the static value buffer
2626
const COAP_VALUE_SIZE: usize = 32;
2727

28-
/// Global CBOR root map
28+
/// Global CBOR root map for encoding CBOR documents
2929
static mut cbor_encoder0: CborEncoder = fill_zero!(CborEncoder);
3030
static mut cbor_encoder1: CborEncoder = fill_zero!(CborEncoder);
3131

3232
impl CoapContext {
3333

34+
/// Encode a text value into the current JSON document with the specified key
3435
pub fn json_set_text_string(&mut self, key: &Strn, value: &Strn) {
36+
// Convert the key to C string.
3537
let key_cstr: *const u8 =
3638
match key.rep {
3739
StrnRep::ByteStr(bs) => { self.key_to_cstr(bs) }
3840
StrnRep::CStr(cstr) => { cstr }
3941
};
42+
// Convert the value to a C string.
4043
let value_cstr: *const u8 =
4144
match value.rep {
4245
StrnRep::ByteStr(bs) => { self.value_to_cstr(bs) }
4346
StrnRep::CStr(cstr) => { cstr }
4447
};
48+
// Encode the value.
4549
unsafe {
4650
crate::libs::mynewt_rust::json_helper_set_text_string(
4751
self.to_void_ptr(),

0 commit comments

Comments
 (0)