Update 'src/lib.rs'

Added doc comments.
This commit is contained in:
Thelie 2021-05-05 19:52:12 +02:00
parent b23709917e
commit 455c49dbb2

View file

@ -21,15 +21,25 @@ pub use self::error::*;
use std::io::{Read, Write}; use std::io::{Read, Write};
use irc_proto::message::Message; use irc_proto::message::Message;
//! This crate provides the `IrcRead` and `IrcWrite` traits and
//! the IrcStream struct that implements them.
/// A trait that mirrors std::io::Read;
/// It requires the `read()` method that returns an IRC Message.
/// The function may or may not block.
pub trait IrcRead{ pub trait IrcRead{
fn read(&mut self) -> Result<Message>; fn read(&mut self) -> Result<Message>;
} }
/// A trait that mirrors std::io::Write;
/// It requires the `write()` and `flush()` methods that returns an IRC Message.
pub trait IrcWrite{ pub trait IrcWrite{
fn write(&mut self, message: Message) -> Result<()>; fn write(&mut self, message: Message) -> Result<()>;
fn flush(&mut self) -> Result<()>; fn flush(&mut self) -> Result<()>;
} }
/// A struct that wraps a generic stream implementing std::io::Read and std::io::Write
/// and implements the IrcRead and IrcWrite traits.
pub struct IrcStream<S: Read + Write> { pub struct IrcStream<S: Read + Write> {
stream:S, stream:S,
buffer:String buffer:String