pub trait SocketOptions: AsRawFd {
// Provided methods
fn set_socket_option<T>(
&self,
level: c_int,
name: c_int,
val: &T,
) -> IoResult<()> { ... }
fn set_socket_option_mult<T>(
&self,
level: c_int,
name: c_int,
values: &[T],
) -> IoResult<()> { ... }
fn set_filters<F>(&self, filters: &[F]) -> IoResult<()>
where F: Into<CanFilter> + Copy { ... }
fn set_filter_drop_all(&self) -> IoResult<()> { ... }
fn set_filter_accept_all(&self) -> IoResult<()> { ... }
fn set_error_filter(&self, mask: u32) -> IoResult<()> { ... }
fn set_error_filter_drop_all(&self) -> IoResult<()> { ... }
fn set_error_filter_accept_all(&self) -> IoResult<()> { ... }
fn set_error_mask(&self, mask: u32) -> IoResult<()> { ... }
fn set_loopback(&self, enabled: bool) -> IoResult<()> { ... }
fn set_recv_own_msgs(&self, enabled: bool) -> IoResult<()> { ... }
fn set_join_filters(&self, enabled: bool) -> IoResult<()> { ... }
}
Expand description
Traits for setting CAN socket options.
These are blocking calls, even when implemented on asynchronous sockets.
Provided Methods§
Sourcefn set_socket_option<T>(
&self,
level: c_int,
name: c_int,
val: &T,
) -> IoResult<()>
fn set_socket_option<T>( &self, level: c_int, name: c_int, val: &T, ) -> IoResult<()>
Sets an option on the socket.
The libc setsockopt
function is set to set various options on a socket.
set_socket_option
offers a somewhat type-safe wrapper that does not
require messing around with *const c_void
s.
A proper std::io::Error
will be returned on failure.
Example use:
sock.set_socket_option(SOL_TCP, TCP_NO_DELAY, 1 as c_int)
Note that the val
parameter must be specified correctly; if an option
expects an integer, it is advisable to pass in a c_int
, not the default
of i32
.
Sourcefn set_socket_option_mult<T>(
&self,
level: c_int,
name: c_int,
values: &[T],
) -> IoResult<()>
fn set_socket_option_mult<T>( &self, level: c_int, name: c_int, values: &[T], ) -> IoResult<()>
Sets a collection of multiple socke options with one call.
Sourcefn set_filters<F>(&self, filters: &[F]) -> IoResult<()>
fn set_filters<F>(&self, filters: &[F]) -> IoResult<()>
Sets CAN ID filters on the socket.
CAN packages received by SocketCAN are matched against these filters, only matching packets are returned by the interface.
See CanFilter
for details on how filtering works. By default, all
single filter matching all incoming frames is installed.
Sourcefn set_filter_drop_all(&self) -> IoResult<()>
fn set_filter_drop_all(&self) -> IoResult<()>
Disable reception of CAN frames.
Sets a completely empty filter; disabling all CAN frame reception.
Sourcefn set_filter_accept_all(&self) -> IoResult<()>
fn set_filter_accept_all(&self) -> IoResult<()>
Accept all frames, disabling any kind of filtering.
Replace the current filter with one containing a single rule that acceps all CAN frames.
Sourcefn set_error_filter(&self, mask: u32) -> IoResult<()>
fn set_error_filter(&self, mask: u32) -> IoResult<()>
Sets the error mask on the socket.
By default (ERR_MASK_NONE
) no error conditions are reported as
special error frames by the socket. Enabling error conditions by
setting ERR_MASK_ALL
or another non-empty error mask causes the
socket to receive notification about the specified conditions.
Sourcefn set_error_filter_drop_all(&self) -> IoResult<()>
fn set_error_filter_drop_all(&self) -> IoResult<()>
Sets the error mask on the socket to reject all errors.
Sourcefn set_error_filter_accept_all(&self) -> IoResult<()>
fn set_error_filter_accept_all(&self) -> IoResult<()>
Sets the error mask on the socket to accept all errors.
Sourcefn set_error_mask(&self, mask: u32) -> IoResult<()>
fn set_error_mask(&self, mask: u32) -> IoResult<()>
Sets the error mask on the socket.
By default (ERR_MASK_NONE
) no error conditions are reported as
special error frames by the socket. Enabling error conditions by
setting ERR_MASK_ALL
or another non-empty error mask causes the
socket to receive notification about the specified conditions.
Sourcefn set_loopback(&self, enabled: bool) -> IoResult<()>
fn set_loopback(&self, enabled: bool) -> IoResult<()>
Enable or disable loopback.
By default, loopback is enabled, causing other applications that open the same CAN bus to see frames emitted by different applications on the same system.
Sourcefn set_recv_own_msgs(&self, enabled: bool) -> IoResult<()>
fn set_recv_own_msgs(&self, enabled: bool) -> IoResult<()>
Enable or disable receiving of own frames.
When loopback is enabled, this settings controls if CAN frames sent are received back immediately by sender. Default is off.
Sourcefn set_join_filters(&self, enabled: bool) -> IoResult<()>
fn set_join_filters(&self, enabled: bool) -> IoResult<()>
Enable or disable join filters.
By default a frame is accepted if it matches any of the filters set
with set_filters
. If join filters is enabled, a frame has to match
all filters to be accepted.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.