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
use {Parcel, Settings, Error};
use std::rc::Rc;
use std::sync::Arc;
use std::ops::Deref;
use std::io::prelude::*;
macro_rules! impl_smart_ptr_type {
($ty:ident) => {
impl<T: Parcel> Parcel for $ty<T>
{
const TYPE_NAME: &'static str = stringify!($ty<T>);
fn read(read: &mut Read, settings: &Settings) -> Result<Self, Error> {
let value = T::read(read, settings)?;
Ok($ty::new(value))
}
fn write(&self, write: &mut Write,
settings: &Settings) -> Result<(), Error> {
self.deref().write(write, settings)
}
}
}
}
impl_smart_ptr_type!(Rc);
impl_smart_ptr_type!(Arc);