use super::{Pid, Tid};
use data_stream::{from_stream, numbers::EndianSettings, to_stream, FromStream, ToStream};
use std::io::{Read, Result, Write};
impl<S: EndianSettings> ToStream<S> for Tid {
fn to_stream<W: Write>(&self, stream: &mut W) -> Result<()> {
to_stream::<S, _, _>(&(self.index as u32), stream)
}
}
impl<S: EndianSettings> ToStream<S> for Pid {
fn to_stream<W: Write>(&self, stream: &mut W) -> Result<()> {
to_stream::<S, _, _>(&(self.index as u32), stream)
}
}
impl<S: EndianSettings> FromStream<S> for Tid {
fn from_stream<R: Read>(stream: &mut R) -> Result<Self> {
let n: u32 = from_stream::<S, _, _>(stream)?;
Ok(Self::new(n as usize))
}
}
impl<S: EndianSettings> FromStream<S> for Pid {
fn from_stream<R: Read>(stream: &mut R) -> Result<Self> {
let n: u32 = from_stream::<S, _, _>(stream)?;
Ok(Self::new(n as usize))
}
}