Added debug derivations for irc::client types (fixes #104).

This commit is contained in:
Aaron Weiss 2018-01-27 20:39:35 +01:00
parent ce158fc612
commit de6e5f331d
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF
2 changed files with 23 additions and 1 deletions

View file

@ -55,6 +55,25 @@ pub enum ConnectionFuture<'a> {
Mock(&'a Config), Mock(&'a Config),
} }
impl<'a> fmt::Debug for ConnectionFuture<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}({:?}, ...)",
match *self {
ConnectionFuture::Unsecured(_, _) => "ConnectionFuture::Unsecured",
ConnectionFuture::Secured(_, _) => "ConnectionFuture::Secured",
ConnectionFuture::Mock(_) => "ConnectionFuture::Mock",
},
match *self {
ConnectionFuture::Unsecured(cfg, _) |
ConnectionFuture::Secured(cfg, _) |
ConnectionFuture::Mock(cfg) => cfg,
}
)
}
}
impl<'a> Future for ConnectionFuture<'a> { impl<'a> Future for ConnectionFuture<'a> {
type Item = Connection; type Item = Connection;
type Error = error::Error; type Error = error::Error;

View file

@ -203,6 +203,7 @@ pub trait Server {
/// traditional use cases. To learn more, you can view the documentation for the /// traditional use cases. To learn more, you can view the documentation for the
/// [futures](https://docs.rs/futures/) crate, or the tutorials for /// [futures](https://docs.rs/futures/) crate, or the tutorials for
/// [tokio](https://tokio.rs/docs/getting-started/futures/). /// [tokio](https://tokio.rs/docs/getting-started/futures/).
#[derive(Debug)]
pub struct ServerStream { pub struct ServerStream {
state: Arc<ServerState>, state: Arc<ServerState>,
stream: SplitStream<Connection>, stream: SplitStream<Connection>,
@ -224,6 +225,7 @@ impl Stream for ServerStream {
} }
/// Thread-safe internal state for an IRC server connection. /// Thread-safe internal state for an IRC server connection.
#[derive(Debug)]
struct ServerState { struct ServerState {
/// The configuration used with this connection. /// The configuration used with this connection.
config: Config, config: Config,
@ -597,7 +599,7 @@ impl ServerState {
/// server after connection. Cloning an `IrcServer` is relatively cheap, as it's equivalent to /// server after connection. Cloning an `IrcServer` is relatively cheap, as it's equivalent to
/// cloning a single `Arc`. This may be useful for setting up multiple threads with access to one /// cloning a single `Arc`. This may be useful for setting up multiple threads with access to one
/// connection. /// connection.
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct IrcServer { pub struct IrcServer {
/// The internal, thread-safe server state. /// The internal, thread-safe server state.
state: Arc<ServerState>, state: Arc<ServerState>,
@ -801,6 +803,7 @@ impl IrcServer {
/// use cases. To learn more, you can view the documentation for the /// use cases. To learn more, you can view the documentation for the
/// [futures](https://docs.rs/futures/) crate, or the tutorials for /// [futures](https://docs.rs/futures/) crate, or the tutorials for
/// [tokio](https://tokio.rs/docs/getting-started/futures/). /// [tokio](https://tokio.rs/docs/getting-started/futures/).
#[derive(Debug)]
pub struct IrcServerFuture<'a> { pub struct IrcServerFuture<'a> {
conn: ConnectionFuture<'a>, conn: ConnectionFuture<'a>,
handle: Handle, handle: Handle,