Commit 4dfd1ef9 authored by Ian Jackson's avatar Ian Jackson
Browse files

Replace manual Default and new with std derive in tor-dirclient

parent e45a95f6
Loading
Loading
Loading
Loading
+6 −30
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ impl Requestable for ConsensusRequest {
}

/// A request for one or more authority certificates.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct AuthCertRequest {
    /// The identity/signing keys of the certificates we want.
    ids: Vec<AuthCertKeyIds>,
@@ -162,7 +162,7 @@ pub struct AuthCertRequest {
impl AuthCertRequest {
    /// Create a new request, asking for no authority certificates.
    pub fn new() -> Self {
        AuthCertRequest { ids: Vec::new() }
        AuthCertRequest::default()
    }

    /// Add `ids` to the list of certificates we're asking for.
@@ -176,12 +176,6 @@ impl AuthCertRequest {
    }
}

impl Default for AuthCertRequest {
    fn default() -> Self {
        Self::new()
    }
}

impl Requestable for AuthCertRequest {
    fn make_request(&self) -> Result<http::Request<()>> {
        let mut ids = self.ids.clone();
@@ -227,7 +221,7 @@ impl FromIterator<AuthCertKeyIds> for AuthCertRequest {
}

/// A request for one or more microdescriptors
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct MicrodescRequest {
    /// The SHA256 digests of the microdescriptors we want.
    digests: Vec<MdDigest>,
@@ -236,9 +230,7 @@ pub struct MicrodescRequest {
impl MicrodescRequest {
    /// Construct a request for no microdescriptors.
    pub fn new() -> Self {
        MicrodescRequest {
            digests: Vec::new(),
        }
        MicrodescRequest::default()
    }
    /// Add `d` to the list of microdescriptors we want to request.
    pub fn push(&mut self, d: MdDigest) {
@@ -251,12 +243,6 @@ impl MicrodescRequest {
    }
}

impl Default for MicrodescRequest {
    fn default() -> Self {
        Self::new()
    }
}

impl Requestable for MicrodescRequest {
    fn make_request(&self) -> Result<http::Request<()>> {
        // TODO: require that self.digests is nonempty.
@@ -296,7 +282,7 @@ impl FromIterator<MdDigest> for MicrodescRequest {
}

/// A request for one, many or all router descriptors.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
#[cfg(feature = "routerdesc")]
pub struct RouterDescRequest {
    /// If this is set, we just ask for all the descriptors.
@@ -307,13 +293,6 @@ pub struct RouterDescRequest {
    digests: Vec<RdDigest>,
}

#[cfg(feature = "routerdesc")]
impl Default for RouterDescRequest {
    fn default() -> Self {
        Self::new()
    }
}

#[cfg(feature = "routerdesc")]
impl RouterDescRequest {
    /// Construct a request for all router descriptors.
@@ -325,10 +304,7 @@ impl RouterDescRequest {
    }
    /// Construct a new empty request.
    pub fn new() -> Self {
        RouterDescRequest {
            all_descriptors: false,
            digests: Vec::new(),
        }
        RouterDescRequest::default()
    }
    /// Add `d` to the list of digests we want to request.
    pub fn push(&mut self, d: RdDigest) {