Add docs for accept and connect

This commit is contained in:
Steven Fackler 2015-06-28 00:21:41 -07:00
parent b1a30ce4ba
commit 797488dd09
1 changed files with 22 additions and 0 deletions

View File

@ -1017,6 +1017,11 @@ impl<S> fmt::Debug for SslStream<S> where S: fmt::Debug {
#[cfg(unix)]
impl<S: ::std::os::unix::io::AsRawFd> SslStream<S> {
/// Creates an SSL/TLS client operating over the provided stream.
///
/// `connect_direct` creates a more efficient `SslStream` than `connect`
/// does, but requires that the stream implement `AsRawFd` on Unix and
/// `AsRawSocket` on Windows.
pub fn connect_direct<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let ssl = try!(ssl.into_ssl());
let fd = stream.as_raw_fd() as c_int;
@ -1026,6 +1031,11 @@ impl<S: ::std::os::unix::io::AsRawFd> SslStream<S> {
})
}
/// Creates an SSL/TLS server operating over the provided stream.
///
/// `accept_direct` creates a more efficient `SslStream` than `accept`
/// does, but requires that the stream implement `AsRawFd` on Unix and
/// `AsRawSocket` on Windows.
pub fn accept_direct<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let ssl = try!(ssl.into_ssl());
let fd = stream.as_raw_fd() as c_int;
@ -1038,6 +1048,11 @@ impl<S: ::std::os::unix::io::AsRawFd> SslStream<S> {
#[cfg(windows)]
impl<S: ::std::os::windows::io::AsRawSocket> SslStream<S> {
/// Creates an SSL/TLS client operating over the provided stream.
///
/// `connect_direct` creates a more efficient `SslStream` than `connect`
/// does, but requires that the stream implement `AsRawFd` on Unix and
/// `AsRawSocket` on Windows.
pub fn new_client_direct<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let fd = stream.as_raw_socket() as c_int;
let stream = try!(DirectStream::connect(ssl, stream, fd));
@ -1046,6 +1061,11 @@ impl<S: ::std::os::windows::io::AsRawSocket> SslStream<S> {
})
}
/// Creates an SSL/TLS server operating over the provided stream.
///
/// `accept_direct` creates a more efficient `SslStream` than `accept`
/// does, but requires that the stream implement `AsRawFd` on Unix and
/// `AsRawSocket` on Windows.
pub fn new_server_direct<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let fd = stream.as_raw_socket() as c_int;
let stream = try!(DirectStream::accept(ssl, stream, fd));
@ -1056,6 +1076,7 @@ impl<S: ::std::os::windows::io::AsRawSocket> SslStream<S> {
}
impl<S: Read+Write> SslStream<S> {
/// Creates an SSL/TLS client operating over the provided stream.
pub fn connect<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let stream = try!(IndirectStream::connect(ssl, stream));
Ok(SslStream {
@ -1063,6 +1084,7 @@ impl<S: Read+Write> SslStream<S> {
})
}
/// Creates an SSL/TLS server operating over the provided stream.
pub fn accept<T: IntoSsl>(ssl: T, stream: S) -> Result<SslStream<S>, SslError> {
let stream = try!(IndirectStream::accept(ssl, stream));
Ok(SslStream {