Ipcon

Struct Ipcon 

Source
pub struct Ipcon { /* private fields */ }
Expand description

IPCON peer.

Implementations§

Source§

impl Ipcon

Source

pub fn to_handler(u: usize) -> *mut c_void

Source

pub unsafe fn from_handler(h: *mut c_void) -> usize

§Safety
Source

pub fn new( peer_name: Option<&str>, flag: Option<IpconFlag>, ) -> Result<Ipcon, IpconError>

Create an IPCON peer. If the name is omitted, an anonymous will be created. Following flags can be specified with bitwise OR (|).

  • IPF_DISABLE_KEVENT_FILTER
    By default, IPCON kernel module will only delivery the add/remove notification of peers and groups which are considered to be interested by the peer. If this flag is enabled, all notification will be delivered by IPCON kernel module.
  • IPF_SND_IF
    Use message sending interface.
  • IPF_RCV_IF
    Use message receiving interface.
  • IPF_DEFAULT
    This is same to IPF_RCV_IF | IPF_SND_IF.
Source

pub fn get_read_fd(&self) -> Result<i32, IpconError>

Retrieve netlink socket file descriptor of message receiving interface.

Source

pub fn get_write_fd(&self) -> Result<i32, IpconError>

Retrieve netlink socket file descriptor of message sending interface.

Source

pub fn get_ctrl_fd(&self) -> Result<i32, IpconError>

Retrieve netlink socket file descriptor of control interface.

Source

pub fn is_peer_present(&self, peer: &str) -> bool

Inquiry whether a peer is present.

Source

pub fn is_group_present(&self, peer: &str, group: &str) -> bool

Inquiry whether the group of a peer is present.

Source

pub fn receive_msg(&self) -> Result<IpconMsg, IpconError>

Receive IPCON message. This function will fail if the peer doesn’t enable IPF_RCV_IF.

Source

pub fn send_unicast_msg(&self, peer: &str, buf: &[u8]) -> Result<(), IpconError>

Send an unicast IPCON message to a specific peer. This function will fail if the peer doesn’t enable IPF_SND_IF.

Source

pub fn send_unicast_msg_by_ref( &self, peer: &str, buf: &[u8], ) -> Result<(), IpconError>

Send an unicast IPCON message to a specific peer. This function will fail if the peer doesn’t enable IPF_SND_IF.

Source

pub fn register_group(&self, group: &str) -> Result<(), IpconError>

Register a multicast group.

Source

pub fn unregister_group(&self, group: &str) -> Result<(), IpconError>

Unregister a multicast group.

Source

pub fn join_group(&self, peer: &str, group: &str) -> Result<(), IpconError>

Subscribe a multicast group of a peer.

Source

pub fn leave_group(&self, peer: &str, group: &str) -> Result<(), IpconError>

Unsubscribe a multicast group of a peer.

Source

pub fn send_multicast( &self, group: &str, buf: &[u8], sync: bool, ) -> Result<(), IpconError>

Send multicast messages to an owned group.

Source

pub fn send_multicast_by_ref( &self, group: &str, buf: &[u8], sync: bool, ) -> Result<(), IpconError>

Send multicast messages to an owned group.

Source

pub fn receive_msg_timeout( &self, tv_sec: u32, tv_usec: u32, ) -> Result<IpconMsg, IpconError>

Receiving message with timeout. receive_msg() will block until a message come. receive_msg_timeout() adds a timeout to it.The timeout is specified with seconds and microseconds.

Source

pub fn receive_msg_nonblock(&self) -> Result<IpconMsg, IpconError>

Receiving message without block. This is same to receive_msg_timeout(0, 0);

Trait Implementations§

Source§

impl Drop for Ipcon

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Ipcon

§

impl RefUnwindSafe for Ipcon

§

impl Send for Ipcon

§

impl Sync for Ipcon

§

impl Unpin for Ipcon

§

impl UnwindSafe for Ipcon

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more