mirror of https://github.com/dswd/vpncloud.git
Removed unused trait
This commit is contained in:
parent
5d006c389c
commit
72b5d9c3fd
|
@ -10,7 +10,7 @@ use std::marker::PhantomData;
|
|||
use time::{Duration, SteadyTime, precise_time_ns};
|
||||
use epoll;
|
||||
|
||||
use super::types::{Table, Protocol, VirtualInterface, Range, Error, NetworkId};
|
||||
use super::types::{Table, Protocol, Range, Error, NetworkId};
|
||||
use super::device::Device;
|
||||
use super::udpmessage::{encode, decode, Options, Message};
|
||||
use super::{ethernet, ip};
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
|||
use std::io::{Result as IoResult, Error as IoError, Read, Write};
|
||||
use std::fs;
|
||||
|
||||
use super::types::{Error, VirtualInterface, Type};
|
||||
use super::types::{Error, Type};
|
||||
|
||||
extern {
|
||||
fn setup_tap_device(fd: i32, ifname: *mut u8) -> i32;
|
||||
|
@ -37,6 +37,17 @@ impl Device {
|
|||
pub fn ifname(&self) -> &str {
|
||||
&self.ifname
|
||||
}
|
||||
|
||||
pub fn read(&mut self, mut buffer: &mut [u8]) -> Result<usize, Error> {
|
||||
self.fd.read(&mut buffer).map_err(|_| Error::TunTapDevError("Read error"))
|
||||
}
|
||||
|
||||
pub fn write(&mut self, data: &[u8]) -> Result<(), Error> {
|
||||
match self.fd.write_all(&data) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(Error::TunTapDevError("Write error"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRawFd for Device {
|
||||
|
@ -44,16 +55,3 @@ impl AsRawFd for Device {
|
|||
self.fd.as_raw_fd()
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualInterface for Device {
|
||||
fn read(&mut self, mut buffer: &mut [u8]) -> Result<usize, Error> {
|
||||
self.fd.read(&mut buffer).map_err(|_| Error::TunTapDevError("Read error"))
|
||||
}
|
||||
|
||||
fn write(&mut self, data: &[u8]) -> Result<(), Error> {
|
||||
match self.fd.write_all(&data) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(Error::TunTapDevError("Write error"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::net::{SocketAddr, Ipv4Addr, Ipv6Addr};
|
||||
use std::hash::Hasher;
|
||||
use std::{fmt, ptr};
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::util::{as_bytes, as_obj};
|
||||
|
@ -113,12 +112,6 @@ pub trait Protocol: Sized {
|
|||
fn parse(&[u8]) -> Result<(Address, Address), Error>;
|
||||
}
|
||||
|
||||
pub trait VirtualInterface: AsRawFd {
|
||||
fn read(&mut self, &mut [u8]) -> Result<usize, Error>;
|
||||
fn write(&mut self, &[u8]) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
ParseError(&'static str),
|
||||
|
|
Loading…
Reference in New Issue