Expand description
§OpenThread API Module
This module contains (mostly) type-safe versions of the OpenThread API, excluding the platform API.
§Type Safety
Full type safety for an API which wasn’t created for type safety is hard. There are some
operations which feel like they should be fully safe but are ultimately marked as unsafe
because it might be possible to abuse in some way that causes undefined behavior.
§Types
Each enum, struct, or object in the OpenThread C API is associated with a safe Rust equivalent. For example:
§Ownership
Some OpenThread API objects, like otsys::otInstance
and
otsys::otMessage
have hidden implementations and explicit ownership
transfer. That means we must have a notation which is capable of both “owned” instances
and “borrowed” references.
The rust equivalent of passing around a pointer to one of thse
objects would be to pass around a reference: otInstance*
becomes a &ot::Instance
.
Owned instances are “boxed” into a ot::Box
, so an owned otInstance*
would become
a ot::Box<ot::Instance>
, or a OtInstanceBox
for short. When the box
goes out of scope, the appropriate OpenThread C finalization API is called.
§Singleton/Multiple OpenThread Instances
OpenThread can be compiled to either only support a singleton instance or to support multiple independent OpenThread instances.
Currently, this crate only supports a singleton OpenThread instance. Attempting to create more than one OpenThread instance at a time will result in a runtime panic.
§Traits
The OpenThread API is broken down into “modules” of functionality containing types and related methods. Similarly, this Rust interface breaks down functionality into traits. This allows parts of the OpenThread API to be substituted with mocked versions for unit testing.
§Callbacks
In most cases, you register a callback by passing a closure to the appropriate callback registration API.
§Platform Implementations
This crate doesn’t directly provide the platform implementations for OpenThread—that needs to come from either a separate library or the program which is using this crate.
Re-exports§
pub use message::Message;
pub use message::MessageBuffer;
Modules§
- Module for all things related to OpenThread messages.
Structs§
- This structure holds information about a network beacon discovered during an active scan.
- Type representing the origin of an address
- Functional equivalent of
otsys::otBackboneRouterMUlticastListenerInfo
. - Error type for when a system time cannot be converted to a timestamp.
- Functional equivalent of
otsys::otBorderRouterConfig
. - This structure represents border routing counters.
- Stream for getting state changed events.
- Represents an entry from the discovered prefix table. Functional equivalent of
otsys::otBorderRoutingPrefixTableEntry
. - A box for owning pointers to opaque types vended from the OpenThread API.
- Type representing a set of radio channels.
- Error type for when a given channel index is out of range.
- Functional equivalent of
otsys::otDnsTxtEntry
. - Functional equivalent of
otsys::otDnsTxtEntryIterator
. - This structure represents DNS-SD server counters.
- Functional equivalent of
otDnssdQuery
- Iterator type for DNS-SD Queries
- This structure holds information about energy levels detected on a channel.
- Data type representing a EUI64 address. Functional equivalent of
otsys::otExtAddress
. - Data type representing an extended PAN-ID. Functional equivalent of
otsys::otExtendedPanId
. - Data type representing an external route configuration. Functional equivalent of
otsys::otExternalRouteConfig
. - OpenThread instance.
- Data type representing an IPv4 CIDR.
- Data type representing IPv6 address information.
- Data type representing a 64-bit IPv6 network prefix.
- IPv6 subnet prefix with an arbitrary prefix length. Functional equivalent of
otsys::otIp6Prefix
. - This structure represents the IP layer counters.
- This structure represents the Thread Leader Data.
- Represents the result (value) for a Link Metrics query.
- Link Mode Config. Functional equivalent of
otsys::otLinkModeConfig
. - Iterator type for external routes.
- Iterator type for on-mesh prefixes.
- This structure represents the MAC layer counters.
- Error type for when an IPv6 header is malformed or there are no buffers to allocate.
- An iterator type for parsing OpenThread TLV data.
- Iterator type for multicast listeners.
- NAT64 Address Mapping, which is part of NAT64 telemetry
- NAT64 Address Mapping iterator
- Represents the counters for NAT64
- Represents the error counters for NAT64
- Counters for sum of all protocols for NAT64
- This structure holds diagnostic information for a neighboring Thread node.
- Iterator type for neighbor info
- Data type representing IPv6 address from a network interface. Functional equivalent of
otsys::otNetifAddress
. - Iterates over the
NetifAddress
structs fromIp6::ip6_get_unicast_addresses()
. - Network Key. Functional equivalent of
otsys::otNetworkKey
. - Network Name. Functional equivalent of
otsys::otNetworkName
. - Error type for when there are no buffers to allocate.
- Platform instance which does nothing.
- Functional equivalent of
otsys::otOperationalDataset
. - Functional equivalent of
otsys::otOperationalDatasetTlvs
. - This structure represents counters for packets and bytes.
- Error type for when there is some sort of parsing error.
- This structure represents border routing counters.
- This structure represents the DNS Upstream Query context.
- Functional equivalent of
otsys::otPlatTrelPeerInfo
. - PSKC. Functional equivalent of
otsys::otPskc
. - This structure represents radio coexistence metrics.
- Represents a radio regulatory region/domain.
- Functional equivalent of
otsys::otRouterInfo
. - Type representing an IPv6 scope, as represented on IPv6 multicast addresses.
- Functional equivalent of
otsys::otSecurityPolicy
. - Functional equivalent of
otsys::otSockAddr
. - This opaque type (only used by reference) represents a SRP host.
- Iterates over the available SRP server hosts. See [
SrpServer::srp_server_get_hosts
]. - This structure represents the SRP Server Lease Info.
- This structure represents SRP server response counters.
- This opaque type (only used by reference) represents a SRP service.
- Iterates over all the available SRP services.
- Iterates over all the available SRP services subtypes.
- The ID of a SRP service update transaction on the SRP Server.
- Stream for getting state changed events.
- Provides an asynchronous interface to
ot::Tasklets
. - Type representing a Thread timestamp.
- This structure represents the Thread TREL counters.
- Functional equivalent of
otsys::otUdpSocket
. - Iterates over the available UDP sockets. See
Udp::udp_get_sockets
. - Represents the count of queries, responses, failures handled by upstream DNS server
- Error type for when a slice is not the correct size.
Enums§
- Represents a Thread device role.
- Represents the thread joiner state.
- This enumeration represents the state of DHCPv6 Prefix Delegation State.
- Represents a Thread device role.
- Represents the type of a DNS query
- Error type for OpenThread calls. Functional equivalent of
otsys::otError
. - Functional equivalent of
otsys::otIcmp6EchoMode
. - Represents the thread joiner state.
- Logging Level. Functional equivalent of
otsys::otLogLevel
. - Logging Region. Functional equivalent of
otsys::otLogRegion
. - Represents a type-length-value (TLV) item.
- Represents a NAT64 Translator State.
- This enumeration defines the OpenThread network interface identifiers.
- Route Preference, as defined in RFC4191 Section 2.1.
- Represents the SRP server address mode.
- Represents the SRP server state.
- Represents the thread version
Constants§
- Unspecified power
- Functional equivalent of
otsys::OT_IP6_PREFIX_BITSIZE
. - The largest child ID supported by OpenThread, 511.
- The maximum length of Thread network data, in bytes.
- The maximum number of individual channels that can be referenced by this API.
- Unspecified network index.
- The bit offset to the router ID in an RLOC16.
- DNS-SD Service Name for TREL
- DNS-SD Service Name for TREL, with a dot at the end.
Traits§
- Methods from the OpenThread “Backbone Router” Module. Currently only multicast routing related methods are added.
- Methods from the OpenThread “Border Agent” Module.
- Methods from the OpenThread “Border Router” Module.
- Trait for OpenThread Rust types for which an owned opaque instance is kept in a [
ot::Box<>
]. - Methods from the OpenThread “CLI” Module.
- Methods from the OpenThread “OperationalDataset” Module.
- DnsUpstream callback from platform to OT
- Methods from the OpenThread DNS-SD Server Module.
- Extension trait for the trait
Dnssd
. - Methods from the “Platform Infrastructure Interface” group [1]
- Trait implemented by all OpenThread instances.
- Trait for converting types into
otError
values. - Methods from the OpenThread “IPv6” Module.
- Methods from the OpenThread “Joiner” Module.
- Methods from the OpenThread “Link” Module.
- Methods from the “Link Metrics “ group [1]
- Methods from the OpenThread “NAT64” Module.
- Methods from the OpenThread “NetData” Module.
- Trait used to indicate that the implementing type can be efficiently converted into a reference to the original OpenThread type identified by
Self::OtType
. - Platform methods from the OpenThread TREL Module.
- Trait for OpenThread platform implementations.
- Trait that provides the [
process_poll()
] method. - Methods from the OpenThread “Radio” Module.
- Reset-related methods from the OpenThread “Instance” Module.
- Server Methods from the OpenThread SRP Module.
- State-change-related methods from the OpenThread “Instance” Module.
- Methods from the OpenThread “Tasklets” Module.
- Trait used to wrap around a mutex that polls internally without needing to externally unlock the mutex.
- Methods from the OpenThread “Thread General” Module.
- Extension trait for adding
tlvs()
method to&[u8]
. - Trait used to indicate that the implementing type can be used by value and converted to/from the associated OpenThread type by value.
- Methods from the OpenThread TREL Module.
- Methods from the OpenThread “UDP” Module.
- Uptime-related methods from the OpenThread “Instance” Module.
Functions§
- Converts a iterator of strings into a single string separated with [
DNSSD_TXT_SEPARATOR_STR
]. - Get the logging level.
- Returns the version of the Thread specification that OpenThread is configured to use. This is the safe equivalent of
otsys::otThreadGetVersion()
. - Returns a
'static
-scoped string slice describing the version of the Thread specification that is currently in use. - Returns the OpenThread version string. This is the safe equivalent of
otsys::otGetVersionString()
. - Functional equivalent of
otsys::otSrpServerParseSubTypeServiceName
. - Extracts the child ID from an RLOC16.
- Extracts the router ID from an RLOC16.
- Changes the logging level.
Type Aliases§
- Channel index value. Identifies an individual radio channel for transmitting and receiving.
- Type for representing decibels, such as RSSI or transmit power.
- IPv4 address type
- IPv6 Address Type. Functional equivalent of
otsys::otIp6Address
. - Mesh-Local Prefix.
- Network Interface Identifier.
- 802.15.4 PAN Identifier. Same type as
otsys::otPanId
. - Type returned by OpenThread calls.
- 802.15.4 Short Address. Same type as
otsys::otShortAddress
.