1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use r2d2;
use std::cell;

#[cfg(feature = "ssl")]
mod config_ssl;
mod config_tcp;
mod pager;
pub mod session;
#[cfg(feature = "ssl")]
mod ssl_connection_pool;
mod tcp_connection_pool;

#[cfg(feature = "ssl")]
pub use cluster::config_ssl::{ClusterSslConfig, NodeSslConfig, NodeSslConfigBuilder};
pub use cluster::config_tcp::{ClusterTcpConfig, NodeTcpConfig, NodeTcpConfigBuilder};
pub use cluster::pager::{QueryPager, SessionPager};
#[cfg(feature = "ssl")]
pub use cluster::ssl_connection_pool::{new_ssl_pool, SslConnectionPool, SslConnectionsManager};
pub use cluster::tcp_connection_pool::{
  new_tcp_pool, startup, TcpConnectionPool, TcpConnectionsManager,
};

use compression::Compression;
use error;
use query::{BatchExecutor, ExecExecutor, PrepareExecutor, QueryExecutor};
use transport::CDRSTransport;

/// `GetConnection` trait provides a unified interface for Session to get a connection
/// from a load balancer
pub trait GetConnection<
  T: CDRSTransport + Send + Sync + 'static,
  M: r2d2::ManageConnection<Connection = cell::RefCell<T>, Error = error::Error>,
>
{
  /// Returns connection from a load balancer.
  fn get_connection(&self) -> Option<r2d2::PooledConnection<M>>;
}

/// `GetCompressor` trait provides a unified interface for Session to get a compressor
/// for further decompressing received data.
pub trait GetCompressor<'a> {
  /// Returns actual compressor.
  fn get_compressor(&self) -> Compression;
}

/// `CDRSSession` trait wrap ups whole query functionality. Use it only if whole query
/// machinery is needed and direct sub traits otherwise.
pub trait CDRSSession<
  'a,
  T: CDRSTransport + 'static,
  M: r2d2::ManageConnection<Connection = cell::RefCell<T>, Error = error::Error>,
>:
  GetCompressor<'static>
  + GetConnection<T, M>
  + QueryExecutor<T, M>
  + PrepareExecutor<T, M>
  + ExecExecutor<T, M>
  + BatchExecutor<T, M>
{
}