pub struct CoapResponse { /* private fields */ }

Implementations

Creates a new CoAP response with the given message type and code.

Returns an error if the given message type is not allowed for CoAP responses (the allowed message types are CoapMessageType::Con and CoapMessageType::Non and CoapMessageType::Ack).

Returns the “Max-Age” option value for this response.

Sets the “Max-Age” option value for this response.

This option indicates the maximum time a response may be cached (in seconds).

See RFC 7252, Section 5.10.5 for more information.

Returns the “Content-Format” option value for this request.

Sets the “Content-Format” option value for this response.

This option indicates the content format of the body of this message.

See RFC 7252, Section 5.10.3 for more information.

Returns the “ETag” option value for this request.

Sets the “ETag” option value for this response.

This option can be used by clients to request a specific representation of the requested resource.

The server may send an ETag value alongside a response, which the client can then set here to request the given representation.

See RFC 7252, Section 5.10.6 for more information.

Returns the “Observe” option value for this request.

Sets the “Observe” option value for this response.

This option indicates that this response is a notification for a previously requested resource observation.

This option is defined in RFC 7641 and is not part of the main CoAP spec. Some peers may therefore not support this option.

Returns the “Location” option value for this request.

Sets the “Location-Path” and “Location-Query” option values for this response.

These options indicate a relative URI for a resource created in response of a POST or PUT request.

The supplied URI must be relative to the requested path and must therefore also not contain a scheme, host or port. Also, each path component must be smaller than 255 characters.

If an invalid URI is provided, an OptionValueError is returned

See RFC 7252, Section 5.10.7 for more information.

Converts this request into a CoapMessage that can be sent over a CoapSession.

Parses the given CoapMessage into a CoapResponse.

Returns a MessageConversionError if the provided PDU cannot be parsed into a response.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Sets the message code of this response.

Panics

Panics if the provided message code is not a response code.

Returns a reference to this message.
Returns a mutable reference to this message.
Add the supplied CoAP option to this message.
Clear the list of options that were added to this message using add_option().
Returns an iterator over the options contained in this message.
Returns the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.
Sets the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.
Returns the message code of this message. To determine whether the message is a request or response, use CoapMessageCode::try_from() and match for the enum variants. Read more
Returns the CoAP message ID for this message.
Sets the CoAP message ID for this message.
Returns a reference to the data/body of this message.
Sets the data/body of this message.
Returns the message token.
Sets the message token. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.