pub struct Packet {
pub data: Vec<u8>,
/* private fields */
}Fields§
§data: Vec<u8>Implementations§
Source§impl Packet
impl Packet
Sourcepub fn header(&self) -> &Header
pub fn header(&self) -> &Header
Examples found in repository?
examples/rx.rs (line 13)
3fn main() -> std::io::Result<()> {
4 let sock = UdpSocket::bind("0.0.0.0:6980")?;
5 loop {
6 let mut buf = [0; vban::MAX_PACKET_SIZE];
7 let (amt, _src) = sock.recv_from(&mut buf)?;
8
9 if let Ok(pkt) = vban::Packet::try_from(&buf[..amt]) {
10 // Check IP of _src
11
12 // Check stream name
13 if pkt.header().stream_name() == "DemoStream" {
14 let _data_size = amt - vban::HEADER_SIZE;
15 print!("Inbound packet! ");
16
17 match pkt.header().sub_protocol() {
18 vban::SubProtocol::Audio => match pkt.header().codec() {
19 vban::Codec::PCM => {
20 println!("{} samples", pkt.data.len());
21 }
22 _ => (),
23 },
24 _ => (),
25 }
26 }
27 }
28 }
29}pub fn header_mut(&mut self) -> &mut Header
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnsafeUnpin for Packet
impl UnwindSafe for Packet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more