fix some warnings (mostly about deprecated stuff)

This commit is contained in:
Stefan Bühler 2019-07-01 10:57:57 +02:00
parent 2e5a46e1b1
commit 0abbb48e1d
7 changed files with 29 additions and 37 deletions

View File

@ -148,12 +148,11 @@ impl<'a> DnsLabelRef<'a> {
}
fn compare_ascii_lc(lhs: &[u8], rhs: &[u8]) -> Ordering {
use std::ascii::AsciiExt;
use std::cmp::min;
let l = min(lhs.len(), rhs.len());
for i in 0..l {
let a : u8 = AsciiExt::to_ascii_lowercase(&lhs[i]);
let b : u8 = AsciiExt::to_ascii_lowercase(&rhs[i]);
let a: u8 = lhs[i].to_ascii_lowercase();
let b: u8 = rhs[i].to_ascii_lowercase();
match Ord::cmp(&a, &b) {
Ordering::Equal => continue,
c => return c,
@ -170,8 +169,7 @@ impl<'a> From<&'a DnsLabel> for DnsLabelRef<'a> {
impl<'a, 'b> PartialEq<DnsLabelRef<'a>> for DnsLabelRef<'b> {
fn eq(&self, rhs: &DnsLabelRef<'a>) -> bool {
use std::ascii::AsciiExt;
AsciiExt::eq_ignore_ascii_case(self.as_raw(), rhs.as_raw())
self.as_raw().eq_ignore_ascii_case(rhs.as_raw())
}
}

View File

@ -48,27 +48,6 @@ pub trait RRDataText {
fn dns_format_rr_data(&self, f: &mut DnsTextFormatter) -> fmt::Result;
fn rr_type_txt(&self) -> Cow<'static, str>;
// (type, rrdata)
fn text(&self) -> Result<(String, String)>
where
Self: RRDataPacket,
{
let mut buf = String::new();
match self.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)) {
Ok(()) => {
return Ok((self.rr_type_txt().into(), buf))
},
Err(_) => (),
}
let mut raw = Vec::new();
self.serialize_rr_data(&mut DnsPacketWriteContext::new(), &mut raw)?;
let ur = UnknownRecord::new(self.rr_type(), raw.into());
// formatting UnknownRecord should not fail
buf.clear();
ur.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)).expect("formatting UnknownRecord must not fail");
Ok((ur.rr_type_txt().into(), buf))
}
}
impl<T: DnsTextData + StaticRRData> RRDataText for T {
@ -98,6 +77,24 @@ pub trait RRData: RRDataPacket + RRDataText + fmt::Debug + 'static {
fn clone_box(&self) -> Box<RRData>;
fn as_any(&self) -> &Any;
// (type, rrdata)
fn text(&self) -> Result<(String, String)> {
let mut buf = String::new();
match self.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)) {
Ok(()) => {
return Ok((self.rr_type_txt().into(), buf))
},
Err(_) => (),
}
let mut raw = Vec::new();
self.serialize_rr_data(&mut DnsPacketWriteContext::new(), &mut raw)?;
let ur = UnknownRecord::new(self.rr_type(), raw.into());
// formatting UnknownRecord should not fail
buf.clear();
ur.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)).expect("formatting UnknownRecord must not fail");
Ok((ur.rr_type_txt().into(), buf))
}
}
impl Clone for Box<RRData> {

View File

@ -5,11 +5,11 @@ mod std_impls;
pub mod quoted;
pub fn skip_whitespace(data: &mut &str) {
*data = (*data).trim_left();
*data = (*data).trim_start();
}
pub fn next_field<'a>(data: &mut &'a str) -> ::errors::Result<&'a str> {
*data = (*data).trim_left();
*data = (*data).trim_start();
if data.is_empty() { bail!("missing field"); }
match data.find(char::is_whitespace) {
None => {
@ -19,14 +19,14 @@ pub fn next_field<'a>(data: &mut &'a str) -> ::errors::Result<&'a str> {
},
Some(next) => {
let result = &(*data)[..next];
*data = &(*data)[next..].trim_left();
*data = &(*data)[next..].trim_start();
Ok(result)
},
}
}
pub fn next_quoted_field(data: &mut &str) -> ::errors::Result<Vec<u8>> {
*data = (*data).trim_left();
*data = (*data).trim_start();
if data.is_empty() { bail!("missing field"); }
let result = quoted::UnquoteIterator::new(data).collect::<Result<Vec<_>, _>>()?;

View File

@ -149,14 +149,14 @@ impl<'a, 'b: 'a> Iterator for UnquoteIterator<'a, 'b> {
}
// eat terminating quote
// pos+1 is obviously a good utf-8 boundary
*self.data = self.data[self.pos+1..].trim_left();
*self.data = self.data[self.pos+1..].trim_start();
return None;
} else {
return self.err("quote in the middle of unquoted string");
}
} else if !self.quoted && is_ascii_whitespace(raw[self.pos]) {
// pos is obviously a good utf-8 boundary
*self.data = self.data[self.pos..].trim_left();
*self.data = self.data[self.pos..].trim_start();
return None;
} else if raw[self.pos] == b'\\' {
if self.pos + 1 >= raw.len() { return self.err("unexpected end of string after backslash"); }

View File

@ -97,7 +97,7 @@ pub fn build(ast: &syn::DeriveInput) -> quote::Tokens {
#[test]
fn test_registry() {
registry::check_registration::<#name>();
registry::check_registration::<super::#name>();
}
}
}

View File

@ -1,13 +1,11 @@
use dnsbox_base::common_types::{Type, DnsName};
use dnsbox_base::failure::Error;
use dnsbox_base::packet::Resource;
use dnsbox_base::ser::RRData;
use futures::{Future, Poll, Async};
use futures::unsync::oneshot;
use std::cell::RefCell;
use std::collections::HashMap;
use std::mem::replace;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::rc::Rc;
use std::time::Duration;

View File

@ -1,6 +1,5 @@
use dnsbox_base::common_types::{types, classes};
use dnsbox_base::common_types::{types};
use dnsbox_base::common_types::{DnsName, DnsCompressedName};
use dnsbox_base::packet::Resource;
use dnsbox_base::records::{NS, A, AAAA};
use dnsbox_base::ser::RRData;
use std::net::{Ipv4Addr, Ipv6Addr};