Struct tiberius::ConnectEndpoint [] [src]

pub struct ConnectEndpoint<I, T: ToIo<I>> where
    I: BoxableIo + Sized + 'static, 
{ /* fields omitted */ }

A target address and connection settings = all that's required to connect to a SQL server

Example

This allows to explicitly construct the connection parameters.
This might be useful for connecting to an underlying IO that isn't supported
within a connection string, such as through a custom protocol implementation.

(In theory it's slightly more efficient, since it should require less dynamic dispatch but is also less flexible because the connection method has to be known at compile time)

use std::net::SocketAddr;
use tiberius::{ConnectParams, EncryptionLevel, SqlConnection};
let addr: SocketAddr = "127.0.0.1:1433".parse().unwrap();
let params = ConnectParams {
    ssl: EncryptionLevel::Required,
    host: "localhost".into(),
    ..ConnectParams::new()
};
// WARNING: This is just so this test can compile, actually you'd want a reactor handle here
let handle = unsafe { ::std::mem::zeroed() };
SqlConnection::connect(handle, (&addr, params));