Commit 1c44dfa5 authored by Ian Jackson's avatar Ian Jackson
Browse files

Replace manual Debug impl with educe in tor-cell

parent b2d8c14c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3092,6 +3092,7 @@ dependencies = [
 "bitflags",
 "bytes",
 "caret",
 "educe",
 "hex",
 "hex-literal",
 "rand 0.8.5",
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ repository="https://gitlab.torproject.org/tpo/core/arti.git/"

[dependencies]
caret = { path="../caret", version = "0.1.0"}
educe = "0.4.6"
tor-llcrypto = { path="../tor-llcrypto", version = "0.1.0"}
tor-bytes = { path="../tor-bytes", version = "0.1.0"}
tor-cert = { path="../tor-cert", version = "0.1.0"}
+5 −7
Original line number Diff line number Diff line
@@ -3,9 +3,10 @@
use super::{ChanCmd, RawCellBody, CELL_DATA_LEN};
use std::convert::TryInto;
use std::net::{IpAddr, Ipv4Addr};
use tor_bytes::{self, Error, Readable, Reader, Result, Writer};
use tor_bytes::{self, skip_fmt, Error, Readable, Reader, Result, Writer};

use caret::caret_int;
use educe::Educe;

/// Trait for the 'bodies' of channel messages.
pub trait Body: Readable {
@@ -431,7 +432,8 @@ impl Readable for Created2 {
///
/// A different protocol is defined over the relay cells; it is implemented
/// in the [crate::relaycell] module.
#[derive(Clone)]
#[derive(Clone, Educe)]
#[educe(Debug)]
pub struct Relay {
    /// The contents of the relay cell as encoded for transfer.
    ///
@@ -440,6 +442,7 @@ pub struct Relay {
    /// places where we _don't_ Box things that we should, and more copies than
    /// necessary happen. We should refactor our data handling until we're mostly
    /// moving around pointers rather than copying data;  see ticket #7.
    #[educe(Debug(method = "skip_fmt"))]
    body: Box<RawCellBody>,
}
impl Relay {
@@ -472,11 +475,6 @@ impl Relay {
        ChanMsg::RelayEarly(self)
    }
}
impl std::fmt::Debug for Relay {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Relay").finish()
    }
}
impl Body for Relay {
    fn into_message(self) -> ChanMsg {
        ChanMsg::Relay(self)