diff --git a/src/encoding.rs b/src/encoding.rs index 0703c788f..920b30e11 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -13,6 +13,7 @@ #[cfg(feature = "query_encoding")] extern crate encoding; use std::borrow::Cow; +#[cfg(feature = "query_encoding")] use std::fmt::{self, Debug, Formatter}; #[cfg(feature = "query_encoding")] use self::encoding::types::{DecoderTrap, EncoderTrap}; #[cfg(feature = "query_encoding")] use self::encoding::label::encoding_from_whatwg_label; @@ -89,9 +90,19 @@ impl EncodingOverride { } } +#[cfg(feature = "query_encoding")] +impl Debug for EncodingOverride { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "EncodingOverride {{ encoding: ")?; + match self.encoding { + Some(e) => write!(f, "{} }}", e.name()), + None => write!(f, "None }}") + } + } +} #[cfg(not(feature = "query_encoding"))] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct EncodingOverride; #[cfg(not(feature = "query_encoding"))] diff --git a/src/form_urlencoded.rs b/src/form_urlencoded.rs index c53acfdec..417211298 100644 --- a/src/form_urlencoded.rs +++ b/src/form_urlencoded.rs @@ -81,7 +81,7 @@ pub fn parse_with_encoding<'a>(input: &'a [u8], } /// The return type of `parse()`. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct Parse<'a> { input: &'a [u8], encoding: EncodingOverride, @@ -145,6 +145,7 @@ impl<'a> Parse<'a> { } /// Like `Parse`, but yields pairs of `String` instead of pairs of `Cow`. +#[derive(Debug)] pub struct ParseIntoOwned<'a> { inner: Parse<'a> } @@ -168,6 +169,7 @@ pub fn byte_serialize(input: &[u8]) -> ByteSerialize { } /// Return value of `byte_serialize()`. +#[derive(Debug)] pub struct ByteSerialize<'a> { bytes: &'a [u8], } @@ -209,6 +211,7 @@ impl<'a> Iterator for ByteSerialize<'a> { /// The [`application/x-www-form-urlencoded` serializer]( /// https://url.spec.whatwg.org/#concept-urlencoded-serializer). +#[derive(Debug)] pub struct Serializer { target: Option, start_position: usize, diff --git a/src/host.rs b/src/host.rs index b93ce1b75..7d4fe13df 100644 --- a/src/host.rs +++ b/src/host.rs @@ -176,7 +176,7 @@ impl> fmt::Display for Host { /// This mostly exists because coherence rules don’t allow us to implement /// `ToSocketAddrs for (Host, u16)`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct HostAndPort { pub host: Host, pub port: u16, @@ -222,10 +222,12 @@ impl> ToSocketAddrs for HostAndPort { } /// Socket addresses for an URL. +#[derive(Debug)] pub struct SocketAddrs { state: SocketAddrsState } +#[derive(Debug)] enum SocketAddrsState { Domain(vec::IntoIter), One(SocketAddr), diff --git a/src/lib.rs b/src/lib.rs index d1fc5cad0..b1e014de8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,7 +122,7 @@ use percent_encoding::{PATH_SEGMENT_ENCODE_SET, USERINFO_ENCODE_SET, use std::borrow::Borrow; use std::cmp; #[cfg(feature = "serde")] use std::error::Error; -use std::fmt::{self, Write}; +use std::fmt::{self, Write, Debug, Formatter}; use std::hash; use std::io; use std::mem; @@ -227,6 +227,16 @@ impl<'a> ParseOptions<'a> { } } +impl<'a> Debug for ParseOptions<'a> { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "ParseOptions {{ base_url: {:?}, encoding_override: {:?}, log_syntax_violation: ", self.base_url, self.encoding_override)?; + match self.log_syntax_violation { + Some(_) => write!(f, "Some(Fn(&'static str)) }}"), + None => write!(f, "None }}") + } + } +} + impl Url { /// Parse an absolute URL from a string. /// @@ -2082,6 +2092,7 @@ fn io_error(reason: &str) -> io::Result { } /// Implementation detail of `Url::query_pairs_mut`. Typically not used directly. +#[derive(Debug)] pub struct UrlQuery<'a> { url: &'a mut Url, fragment: Option, diff --git a/src/path_segments.rs b/src/path_segments.rs index 4418b6918..f5b7d51f9 100644 --- a/src/path_segments.rs +++ b/src/path_segments.rs @@ -33,6 +33,7 @@ use Url; /// # } /// # run().unwrap(); /// ``` +#[derive(Debug)] pub struct PathSegmentsMut<'a> { url: &'a mut Url, after_first_slash: usize, diff --git a/src/percent_encoding.rs b/src/percent_encoding.rs index 90891a627..854ad0e67 100644 --- a/src/percent_encoding.rs +++ b/src/percent_encoding.rs @@ -58,7 +58,7 @@ pub trait EncodeSet: Clone { macro_rules! define_encode_set { ($(#[$attr: meta])* pub $name: ident = [$base_set: expr] | {$($ch: pat),*}) => { $(#[$attr])* - #[derive(Copy, Clone)] + #[derive(Copy, Clone, Debug)] #[allow(non_camel_case_types)] pub struct $name; @@ -77,7 +77,7 @@ macro_rules! define_encode_set { } /// This encode set is used for the path of cannot-be-a-base URLs. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] #[allow(non_camel_case_types)] pub struct SIMPLE_ENCODE_SET; @@ -163,7 +163,7 @@ pub fn utf8_percent_encode(input: &str, encode_set: E) -> PercentE } /// The return type of `percent_encode()` and `utf8_percent_encode()`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PercentEncode<'a, E: EncodeSet> { bytes: &'a [u8], encode_set: E, @@ -249,7 +249,7 @@ pub fn percent_decode(input: &[u8]) -> PercentDecode { } /// The return type of `percent_decode()`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PercentDecode<'a> { bytes: slice::Iter<'a, u8>, }