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
32
33
34
use std::fmt;
use error;
use types;
use utils::Decodeable;
use utils::ReadBytesLocal;
#[derive(Debug, Copy, Clone, Default)]
pub struct Community {
pub asn: u32,
pub tag: u16,
}
impl fmt::Display for Community {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.asn, self.tag)
}
}
impl Decodeable for Community {
#[inline]
fn read_and_decode(stream: &mut types::ReadSeeker) -> Result<Community, error::Error> {
let r = Community {
asn: try!(stream.be_read_u16()) as u32,
tag: try!(stream.be_read_u16()),
};
Ok(r)
}
}