[][src]Function libcoap_sys::coap_write_block_opt

pub unsafe extern "C" fn coap_write_block_opt(
    block: *mut coap_block_t,
    type_: u16,
    pdu: *mut coap_pdu_t,
    data_length: usize
) -> c_int

Writes a block option of type @p type to message @p pdu. If the requested block size is too large to fit in @p pdu, it is reduced accordingly. An exception is made for the final block when less space is required. The actual length of the resource is specified in @p data_length.

This function may change *block to reflect the values written to @p pdu. As the function takes into consideration the remaining space @p pdu, no more options should be added after coap_write_block_opt() has returned.

@param block The block structure to use. On return, this object is updated according to the values that have been written to @p pdu. @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. @param pdu The message where the block option should be written. @param data_length The length of the actual data that will be added the @p pdu by calling coap_add_block().

@return @c 1 on success, or a negative value on error.