Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

associate mtu with the capacity of ReadBuf for all platforms #7

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/async/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ impl AsyncDevice {
}

/// Consumes this AsyncDevice and return a Framed object (unified Stream and Sink interface)
pub fn into_framed(mut self) -> Framed<Self, TunPacketCodec> {
let packet_information = self.get_mut().has_packet_information();
pub fn into_framed(self) -> Framed<Self, TunPacketCodec> {
let packet_information = self.get_ref().has_packet_information();
let mtu = self.inner.get_ref().mtu().unwrap_or(1504);
let codec = TunPacketCodec::new(packet_information, mtu);
Framed::new(self, codec)
// associate mtu with the capacity of ReadBuf
Framed::with_capacity(self, codec, mtu as usize)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/linux/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl Device {
}

/// Return whether the device has packet information
pub fn has_packet_information(&mut self) -> bool {
pub fn has_packet_information(&self) -> bool {
self.queues[0].has_packet_information()
}

Expand Down Expand Up @@ -405,7 +405,7 @@ pub struct Queue {
}

impl Queue {
pub fn has_packet_information(&mut self) -> bool {
pub fn has_packet_information(&self) -> bool {
self.packet_information
}

Expand Down