use core::ops::Deref;
use alloc::rc::Rc;
use psp::sys;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct RawSocketFileDescriptor(pub(crate) i32);
impl Drop for RawSocketFileDescriptor {
fn drop(&mut self) {
unsafe {
sys::sceNetInetClose(self.0);
};
}
}
impl Deref for RawSocketFileDescriptor {
type Target = i32;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SocketFileDescriptor(pub(crate) Rc<RawSocketFileDescriptor>);
impl SocketFileDescriptor {
pub(crate) fn new(fd: i32) -> Self {
Self(Rc::new(RawSocketFileDescriptor(fd)))
}
}
impl Deref for SocketFileDescriptor {
type Target = i32;
fn deref(&self) -> &Self::Target {
&self.0
}
}