Skip to content

Commit

Permalink
Merge pull request AlexPikalov#129 from AlexPikalov/docs-transport
Browse files Browse the repository at this point in the history
Add docs to transport module
  • Loading branch information
AlexPikalov authored Mar 30, 2017
2 parents 5e41596 + 95ea0c9 commit eb35568
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/transport.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
//!This module contains a declaration of `CDRSTransport` trait which should be implemented
//!for particular transport in order to be able using it as a trasport of CDRS client.
//!
//!Curently CDRS provides to concrete transports which implement `CDRSTranpsport` trait. There
//! are:
//!
//! * [`TransportTcp`][tTcp] is default TCP transport which is usually used to establish
//!connection and exchange frames.
//!
//! * `TransportTls` is a transport which is used to establish SSL encrypted connection
//!with Apache Cassandra server. **Note:** this option is available if and only if CDRS is imported
//!with `ssl` feature.
//!
//! # Examples
//!
//!```no_run
//! use cdrs::transport::TransportTcp;
//! use cdrs::authenticators::NoneAuthenticator;
//! use cdrs::client::CDRS;
//!
//! let addr = "127.0.0.1:9042";
//! let tcp_transport = TransportTcp::new(addr).unwrap();
//!
//! // pass authenticator into CDRS' constructor
//! let client = CDRS::new(tcp_transport, NoneAuthenticator);
//!```
//![tTcp]:struct.TransportTcp.html

use std::io;
use std::io::{Read, Write};
use std::net;
Expand All @@ -6,6 +34,11 @@ use std::time::Duration;
#[cfg(feature = "ssl")]
use openssl::ssl::{SslStream, SslConnector};

///General CDRS transport trait. Both [`TranportTcp`][transportTcp]
///and [`TransportTls`][transportTls] has their own implementations of this trait. Generaly
///speaking it extends/includes `io::Read` and `io::Write` traits and should be thread safe.
///[transportTcp]:struct.TransportTcp.html
///[transportTls]:struct.TransportTls.html
pub trait CDRSTransport: Sized + Read + Write + Send + Sync {
/// Creates a new independently owned handle to the underlying socket.
///
Expand All @@ -23,6 +56,7 @@ pub trait CDRSTransport: Sized + Read + Write + Send + Sync {
fn set_timeout(&mut self, dur: Option<Duration>) -> io::Result<()>;
}

/// Default Tcp transport.
pub struct TransportTcp {
tcp: TcpStream,
}
Expand Down

0 comments on commit eb35568

Please sign in to comment.