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 35
#[cfg(test)] mod data_test; use stun::attributes::*; use stun::message::*; use util::Error; // Data represents DATA attribute. // // The DATA attribute is present in all Send and Data indications. The // value portion of this attribute is variable length and consists of // the application data (that is, the data that would immediately follow // the UDP header if the data was been sent directly between the client // and the peer). // // RFC 5766 Section 14.4 #[derive(Default, Debug, PartialEq)] pub struct Data(pub Vec<u8>); impl Setter for Data { // AddTo adds DATA to message. fn add_to(&self, m: &mut Message) -> Result<(), Error> { m.add(ATTR_DATA, &self.0); Ok(()) } } impl Getter for Data { // GetFrom decodes DATA from message. fn get_from(&mut self, m: &Message) -> Result<(), Error> { self.0 = m.get(ATTR_DATA)?; Ok(()) } }