Commit 797488dd authored by Steven Fackler's avatar Steven Fackler
Browse files

Add docs for accept and connect

parent b1a30ce4
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -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 {