Browse Source

refine code

pull/207/head
ssrlive 1 year ago
parent
commit
6a5692cea0
  1. 18
      Cargo.toml
  2. 10
      src/error.rs

18
Cargo.toml

@ -55,17 +55,16 @@ udp-stream = { version = "0.0.12", default-features = false }
unicase = "2" unicase = "2"
url = "2" url = "2"
[build-dependencies] [target.'cfg(target_os="android")'.dependencies]
chrono = "0.4" android_logger = "0.15"
serde_json = "1" jni = { version = "0.21", default-features = false }
[target.'cfg(target_os="linux")'.dependencies] [target.'cfg(target_os="linux")'.dependencies]
serde = { version = "1", features = ["derive"] }
bincode = "2" bincode = "2"
serde = { version = "1", features = ["derive"] }
[target.'cfg(target_os="android")'.dependencies] [target.'cfg(target_os="windows")'.dependencies]
android_logger = "0.15" windows-service = "0.8"
jni = { version = "0.21", default-features = false }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
daemonize = "0.5" daemonize = "0.5"
@ -75,8 +74,9 @@ nix = { version = "0.30", default-features = false, features = [
"uio", "uio",
] } ] }
[target.'cfg(target_os = "windows")'.dependencies] [build-dependencies]
windows-service = "0.8" chrono = "0.4"
serde_json = "1"
# [profile.release] # [profile.release]
# strip = "symbols" # strip = "symbols"

10
src/error.rs

@ -23,7 +23,7 @@ pub enum Error {
TryFromSlice(#[from] std::array::TryFromSliceError), TryFromSlice(#[from] std::array::TryFromSliceError),
#[error("IpStackError {0:?}")] #[error("IpStackError {0:?}")]
IpStack(#[from] ipstack::IpStackError), IpStack(#[from] Box<ipstack::IpStackError>),
#[error("DnsProtoError {0:?}")] #[error("DnsProtoError {0:?}")]
DnsProto(#[from] hickory_proto::ProtoError), DnsProto(#[from] hickory_proto::ProtoError),
@ -45,6 +45,12 @@ pub enum Error {
IntParseError(#[from] std::num::ParseIntError), IntParseError(#[from] std::num::ParseIntError),
} }
impl From<ipstack::IpStackError> for Error {
fn from(err: ipstack::IpStackError) -> Self {
Self::IpStack(Box::new(err))
}
}
impl From<&str> for Error { impl From<&str> for Error {
fn from(err: &str) -> Self { fn from(err: &str) -> Self {
Self::String(err.to_string()) Self::String(err.to_string())
@ -67,7 +73,7 @@ impl From<Error> for std::io::Error {
fn from(err: Error) -> Self { fn from(err: Error) -> Self {
match err { match err {
Error::Io(err) => err, Error::Io(err) => err,
_ => std::io::Error::new(std::io::ErrorKind::Other, err), _ => std::io::Error::other(err),
} }
} }
} }

Loading…
Cancel
Save