[−][src]Trait async_coap::message::MessageWrite
Trait for writing/serializing a CoAP message.
Required methods
fn set_msg_type(&mut self, tt: MsgType)
Sets the CoAP message type. This may be called at any time during message writing without disrupting the operation. It may be called multiple times if necessary. The written value is that of the last call.
fn set_msg_id(&mut self, msg_id: MsgId)
Sets the CoAP message id. This may be called at any time during message writing without disrupting the operation. It may be called multiple times if necessary. The written value is that of the last call.
fn set_msg_code(&mut self, code: MsgCode)
Sets the CoAP message code. This may be called at any time during message writing without disrupting the operation. It may be called multiple times if necessary. The written value is that of the last call.
fn set_msg_token(&mut self, token: MsgToken)
Sets the CoAP message token. Calling this method out-of-order will cause any previously written options or payload to be lost. It may be called multiple times if necessary. The written value is that of the last call.
fn append_payload_bytes(&mut self, body: &[u8]) -> Result<(), Error>
Appends bytes from the given slice body
to the payload of the message.
This method should only be called after the token and all options have been set.
This method may be called multiple times, each time appending data to the payload.
fn clear(&mut self)
Removes the message payload along with all options.
Provided methods
fn append_payload_string(&mut self, body: &str) -> Result<(), Error>
Appends bytes from the UTF8 representation of the given string slice body
to the payload
of the message.
This method should only be called after the token and all options have been set.
This method may be called multiple times, each time appending data to the payload.
fn append_payload_u8(&mut self, b: u8) -> Result<(), Error>
Appends a single byte to the payload of the message. This method should only be called after the token and all options have been set. This method may be called multiple times, each time appending data to the payload.
fn append_payload_char(&mut self, c: char) -> Result<(), Error>
Appends the UTF8 representation for a single unicode character to the payload of the message. This method should only be called after the token and all options have been set. This method may be called multiple times, each time appending data to the payload.
Trait Implementations
impl<'a> Write for dyn MessageWrite + 'a
[src]
fn write_str(&mut self, s: &str) -> Result<(), Error>
[src]
fn write_char(&mut self, c: char) -> Result<(), Error>
[src]
fn write_fmt(&mut self, args: Arguments) -> Result<(), Error>
1.0.0[src]
Glue for usage of the [write!
] macro with implementors of this trait. Read more
impl<'a> Write for dyn MessageWrite + 'a
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
[src]
fn flush(&mut self) -> Result<(), Error>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
Like write
, except that it writes from a slice of buffers. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Write
. Read more