#[non_exhaustive]pub struct DeviceAddress {
pub can_id: Option<u8>,
pub uuid: Option<Vec<u8>>,
pub transport_device: Option<usize>,
}Expand description
Address for a moteus device.
A device address can include a CAN ID, a UUID (or UUID prefix), and a
transport device index. All fields are optional, and both can_id and
uuid can be set simultaneously so that clients can see both identifiers.
The transport_device field specifies which transport device to route
commands through, bypassing automatic device discovery.
§Examples
use moteus::DeviceAddress;
// Address by CAN ID (most common)
let addr = DeviceAddress::can_id(1);
assert_eq!(addr.as_can_id(), Some(1));
// Using From trait
let addr: DeviceAddress = 1.into();
// Address by UUID
let uuid_bytes = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10];
let addr = DeviceAddress::uuid(uuid_bytes);
// UUID prefix (for matching)
let addr = DeviceAddress::uuid([0x01, 0x02, 0x03, 0x04]);
// With transport device routing
let addr = DeviceAddress::can_id(1).with_transport_device(0);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.can_id: Option<u8>CAN bus ID (1-127), if known.
uuid: Option<Vec<u8>>UUID or UUID prefix, if known.
transport_device: Option<usize>Index of the transport device to route through, if known.
Implementations§
Source§impl DeviceAddress
impl DeviceAddress
Sourcepub fn uuid(uuid: impl Into<Vec<u8>>) -> Self
pub fn uuid(uuid: impl Into<Vec<u8>>) -> Self
Create an address from a UUID or UUID prefix.
§Arguments
uuid- Full 16-byte UUID or a prefix for matching
Sourcepub fn with_transport_device(self, idx: usize) -> Self
pub fn with_transport_device(self, idx: usize) -> Self
Set the transport device index (builder pattern).
Trait Implementations§
Source§impl Clone for DeviceAddress
impl Clone for DeviceAddress
Source§fn clone(&self) -> DeviceAddress
fn clone(&self) -> DeviceAddress
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceAddress
impl Debug for DeviceAddress
Source§impl Display for DeviceAddress
impl Display for DeviceAddress
impl Eq for DeviceAddress
Source§impl From<&[u8]> for DeviceAddress
impl From<&[u8]> for DeviceAddress
Source§impl From<i32> for DeviceAddress
impl From<i32> for DeviceAddress
Source§impl From<u8> for DeviceAddress
impl From<u8> for DeviceAddress
Source§impl FromStr for DeviceAddress
Parse a device address from a string.
impl FromStr for DeviceAddress
Parse a device address from a string.
Supports:
- Integer CAN IDs: “1”, “15”, “127”
- Hex UUID or prefix: “01:02:03:04” or “01020304”
Source§impl Hash for DeviceAddress
impl Hash for DeviceAddress
Source§impl PartialEq for DeviceAddress
impl PartialEq for DeviceAddress
impl StructuralPartialEq for DeviceAddress
Auto Trait Implementations§
impl Freeze for DeviceAddress
impl RefUnwindSafe for DeviceAddress
impl Send for DeviceAddress
impl Sync for DeviceAddress
impl Unpin for DeviceAddress
impl UnsafeUnpin for DeviceAddress
impl UnwindSafe for DeviceAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CommandExt for T
impl<T> CommandExt for T
Source§fn with_query(self, format: QueryFormat) -> WithQuery<Self>
fn with_query(self, format: QueryFormat) -> WithQuery<Self>
Attaches a query format override to this command.