use std::{ffi::c_int, fmt, net::Ipv4Addr};
use crate::{IP_DROP_MEMBERSHIP, IPPROTO_IP, OptWMarker, So9IfInder, SockOptMarker, ip_mreqn};
#[repr(transparent)]
#[derive(Clone, Copy)]
pub struct IpDropMembership(ip_mreqn);
#[cfg(unix)]
impl fmt::Debug for IpDropMembership
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
f.debug_tuple("IpDropMembership").field(&self.0).finish()
}
}
#[cfg(windows)]
impl fmt::Debug for IpDropMembership
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
f.debug_tuple("IpDropMembership").finish()
}
}
impl SockOptMarker for IpDropMembership
{
const SO_LEVEL: c_int = IPPROTO_IP;
const SO_OPTNAME: c_int = IP_DROP_MEMBERSHIP;
type DataType = (Ipv4Addr, So9IfInder);
type InputType = ();
#[inline]
fn from(_value: Self::InputType) -> Self
{
panic!("IpDropMembership cannot be read");
}
#[inline]
fn get(self) -> Self::DataType
{
panic!("IpDropMembership cannot be consumed");
}
#[inline]
fn from_user(inp: Self::DataType) -> Self where Self: Sized
{
return Self( inp.1.into_ip_mreqn(&inp.0));
}
}
impl OptWMarker for IpDropMembership {}