use std::fmt;
use std::ffi::c_int;
use windows_sys::Win32::Networking::WinSock::{SO_PROTOCOL_INFOW, SOL_SOCKET, WSAPROTOCOL_INFOW};
use crate::{OptRMarker, So9SockProtocol, SockOptMarker};
#[repr(transparent)]
#[derive(Clone, Copy)]
pub struct SoProtocol(WSAPROTOCOL_INFOW);
impl fmt::Debug for SoProtocol
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
f.debug_tuple("SoProtocol").finish()
}
}
impl SockOptMarker for SoProtocol
{
const SO_LEVEL: c_int = SOL_SOCKET;
const SO_OPTNAME: c_int = SO_PROTOCOL_INFOW;
type DataType = So9SockProtocol;
type InputType = WSAPROTOCOL_INFOW;
#[inline]
fn from(value: Self::InputType) -> Self
{
return Self(value);
}
#[inline]
fn get(self) -> Self::DataType
{
return Self::DataType::from(self.0);
}
#[inline]
fn from_user(_flag: Self::DataType) -> Self where Self: Sized
{
panic!("SoProtocol cannot be written!");
}
}
impl OptRMarker for SoProtocol {}