pub struct CanAddr(/* private fields */);
Expand description
CAN socket address.
This is the address for use with CAN sockets. It is simply an address to the SocketCAN host interface. It can be created by looking up the name of the interface, like “can0”, “vcan0”, etc, or an interface index can be specified directly, if known. An index of zero can be used to read frames from all interfaces.
This is based on, and compatible with, the sockaddr_can
struct from
libc.
ref
Implementations§
Source§impl CanAddr
impl CanAddr
Sourcepub fn new(ifindex: u32) -> Self
pub fn new(ifindex: u32) -> Self
Creates a new CAN socket address for the specified interface by index. An index of zero can be used to read from all interfaces.
Sourcepub fn new_j1939(ifindex: u32, name: u64, pgn: u32, jaddr: u8) -> Self
pub fn new_j1939(ifindex: u32, name: u64, pgn: u32, jaddr: u8) -> Self
Creates a new CAN J1939 socket address for the specified interface by index.
Sourcepub fn new_isotp<R, T>(ifindex: u32, rx_id: R, tx_id: T) -> Self
pub fn new_isotp<R, T>(ifindex: u32, rx_id: R, tx_id: T) -> Self
Creates a new CAN ISO-TP socket address for the specified interface by index.
Sourcepub fn from_iface(ifname: &str) -> Result<Self>
pub fn from_iface(ifname: &str) -> Result<Self>
Try to create an address from an interface name.
Sourcepub fn from_iface_j1939(
ifname: &str,
name: u64,
pgn: u32,
jaddr: u8,
) -> Result<Self>
pub fn from_iface_j1939( ifname: &str, name: u64, pgn: u32, jaddr: u8, ) -> Result<Self>
Try to create a J1939 address from an interface name.
Sourcepub fn from_iface_isotp<R, T>(ifname: &str, rx_id: R, tx_id: T) -> Result<Self>
pub fn from_iface_isotp<R, T>(ifname: &str, rx_id: R, tx_id: T) -> Result<Self>
Try to create a ISO-TP address from an interface name.
Sourcepub fn as_ptr(&self) -> *const sockaddr_can
pub fn as_ptr(&self) -> *const sockaddr_can
Gets the address of the structure as a sockaddr_can
pointer.
Sourcepub fn as_sockaddr_ptr(&self) -> *const sockaddr
pub fn as_sockaddr_ptr(&self) -> *const sockaddr
Gets the address of the structure as a sockaddr
pointer.
Sourcepub fn into_storage(self) -> (sockaddr_storage, socklen_t)
pub fn into_storage(self) -> (sockaddr_storage, socklen_t)
Converts the address into a sockaddr_storage
type.
The storage type is a generic socket address container with enough
space to hold any address in the system (not just CAN addresses).
Sourcepub fn into_sock_addr(self) -> SockAddr
pub fn into_sock_addr(self) -> SockAddr
Converts the address into a socket2::SockAddr
Trait Implementations§
Source§impl AsRef<sockaddr_can> for CanAddr
impl AsRef<sockaddr_can> for CanAddr
Source§fn as_ref(&self) -> &sockaddr_can
fn as_ref(&self) -> &sockaddr_can
Source§impl From<sockaddr_can> for CanAddr
impl From<sockaddr_can> for CanAddr
Source§fn from(addr: sockaddr_can) -> Self
fn from(addr: sockaddr_can) -> Self
impl Copy for CanAddr
Auto Trait Implementations§
impl Freeze for CanAddr
impl RefUnwindSafe for CanAddr
impl Send for CanAddr
impl Sync for CanAddr
impl Unpin for CanAddr
impl UnwindSafe for CanAddr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more