pub struct VTPSocketBuf {
pub packet_count: u64,
/* private fields */
}Expand description
Fields§
§packet_count: u64Counts the number of packets received so far
Implementations§
Source§impl VTPSocketBuf
impl VTPSocketBuf
Sourcepub fn new(socket: UdpSocket, frame_size: usize, framebuf_size: usize) -> Self
pub fn new(socket: UdpSocket, frame_size: usize, framebuf_size: usize) -> Self
Create a new socket buffer attached to socket.
The internal buffer can hold a total of framebuf_size frames of size frame_size at any point.
Sourcepub fn recv_batch(&mut self) -> Result<usize>
pub fn recv_batch(&mut self) -> Result<usize>
Attempt to fill the internal buffer with packets from the socket by calling recvmmsg.
This will overwrite the contents of the buffer, so ensure that you have fetched all the data you need before calling this.
Sourcepub fn recv_frame(&mut self) -> Result<(u64, VDIFFrame)>
pub fn recv_frame(&mut self) -> Result<(u64, VDIFFrame)>
Receive a VDIFFrame from the internal buffer, along with its VTP sequence number.
If all frames have been received, this function will automatically call recv_batch to retrieve more data. Therefore, the user
shouldn’t need to ever worry about calling recv_batch.
Sourcepub fn recv_frame_to(&mut self, dest: &mut [u32]) -> Result<u64>
pub fn recv_frame_to(&mut self, dest: &mut [u32]) -> Result<u64>
Receive a single frame from the internal buffer directed to dest. Directly returns the VTP sequence number in Ok.
If all frames have been received, this function will automatically call recv_batch to retrieve more data. Therefore, the user
shouldn’t need to ever worry about calling recv_batch.