[−][src]Struct async_tun::Tun
Represents a Tun/Tap device. Use TunBuilder
to create a new instance of Tun
.
Implementations
impl Tun
[src]
pub fn name(&self) -> &str
[src]
Returns the name of Tun/Tap device.
pub fn mtu(&self) -> Result<i32>
[src]
Returns the value of MTU.
pub fn address(&self) -> Result<Ipv4Addr>
[src]
Returns the IPv4 address of MTU.
pub fn destination(&self) -> Result<Ipv4Addr>
[src]
Returns the IPv4 destination address of MTU.
pub fn broadcast(&self) -> Result<Ipv4Addr>
[src]
Returns the IPv4 broadcast address of MTU.
pub fn netmask(&self) -> Result<Ipv4Addr>
[src]
Returns the IPv4 netmask address of MTU.
pub fn flags(&self) -> Result<i16>
[src]
Returns the flags of MTU.
Methods from Deref<Target = File>
pub async fn sync_all(&'_ self) -> Result<(), Error>
[src]
Synchronizes OS-internal buffered contents and metadata to disk.
This function will ensure that all in-memory data reaches the filesystem.
This can be used to handle errors that would otherwise only be caught when the file is closed. When a file is dropped, errors in synchronizing this in-memory data are ignored.
Examples
use async_std::fs::File; use async_std::prelude::*; let mut file = File::create("a.txt").await?; file.write_all(b"Hello, world!").await?; file.sync_all().await?;
pub async fn sync_data(&'_ self) -> Result<(), Error>
[src]
Synchronizes OS-internal buffered contents to disk.
This is similar to sync_all
, except that file metadata may not be synchronized.
This is intended for use cases that must synchronize the contents of the file, but don't need the file metadata synchronized to disk.
Note that some platforms may simply implement this in terms of sync_all
.
Examples
use async_std::fs::File; use async_std::prelude::*; let mut file = File::create("a.txt").await?; file.write_all(b"Hello, world!").await?; file.sync_data().await?;
pub async fn set_len(&'_ self, size: u64) -> Result<(), Error>
[src]
Truncates or extends the file.
If size
is less than the current file size, then the file will be truncated. If it is
greater than the current file size, then the file will be extended to size
and have all
intermediate data filled with zeros.
The file's cursor stays at the same position, even if the cursor ends up being past the end of the file after this operation.
Examples
use async_std::fs::File; let file = File::create("a.txt").await?; file.set_len(10).await?;
pub async fn metadata(&'_ self) -> Result<Metadata, Error>
[src]
Reads the file's metadata.
Examples
use async_std::fs::File; let file = File::open("a.txt").await?; let metadata = file.metadata().await?;
pub async fn set_permissions(&'_ self, perm: Permissions) -> Result<(), Error>
[src]
Changes the permissions on the file.
Errors
An error will be returned in the following situations:
- The current process lacks permissions to change attributes on the file.
- Some other I/O error occurred.
Examples
use async_std::fs::File; let file = File::create("a.txt").await?; let mut perms = file.metadata().await?.permissions(); perms.set_readonly(true); file.set_permissions(perms).await?;
Trait Implementations
impl Clone for Tun
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Deref for Tun
[src]
impl DerefMut for Tun
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Tun
impl Send for Tun
impl Sync for Tun
impl Unpin for Tun
impl !UnwindSafe for Tun
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,