1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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))
    }
}