pub struct CoapRequest { /* private fields */ }
Expand description

Representation of a CoAP request message.

This struct wraps around the more direct CoapMessage and allows easier definition of typical options used in requests.

Implementations

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

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

Returns the “Accept” option value for this request.

Sets the “Accept” option value for this request.

This option indicates the acceptable content formats for the response.

See RFC 7252, Section 5.10.4 for more information.

Returns the “ETag” option value for this request.

Sets the “ETag” option value for this request.

This option can be used 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 “If-Match” option value for this request.

Sets the “If-Match” option value for this request.

This option indicates a match expression that must be fulfilled in order to perform the request.

See RFC 7252, Section 5.10.8.1 for more information.

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

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

This option indicates the content format of the body of this message. It is not to be confused with the “Accept” option, which indicates the format that the body of the response to this message should have.

See RFC 7252, Section 5.10.3 for more information.

Returns the “If-None-Match” option value of this request.

Sets the “If-None-Match” option value for this request.

This option indicates that no match expression may be fulfilled in order for this request to be fulfilled.

It is usually nonsensical to set this value to true if an If-Match-Expression has been set.

See RFC 7252, Section 5.10.8.2 for more information.

Returns the “Hop-Limit” option value of this request.

Sets the “Hop-Limit” option value for this request.

This option is mainly used to prevent proxying loops and specifies the maximum number of proxies that the request may pass.

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

Returns the “No-Response” option value for this request.

Sets the “No-Response” option value for this request.

This option indicates that the client performing this request does not wish to receive a response for this request.

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

Returns the “Observe” option value for this request.

Sets the “Observe” option value for this request.

This option indicates that the client performing this request wishes to be notified of changes to the requested resource.

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 CoAP URI that is requested (either a normal request URI or a proxy URI)

Sets the URI requested in this request.

The request URI must not have a scheme defined, and path segments, query segments and the host itself each have to be smaller than 255 characters.

If the URI has an invalid format, an OptionValueError is returned.

This method overrides any previously set proxy URI.

Sets the proxy URI requested in this request.

The proxy URI must be an absolute URL with a schema valid for CoAP proxying (CoAP(s) or HTTP(s)), The proxy URI must not be longer than 1023 characters.

If the URI has an invalid format, an OptionValueError is returned.

This method overrides any previously set request URI.

Parses the given CoapMessage into a CoapRequest.

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

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

Trait Implementations

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

Sets the message code of this request.

Panics

Panics if the provided message code is not a request 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.