Created
December 29, 2016 15:57
-
-
Save AlexPikalov/a202c593b143a4a86f3532c3debed87a to your computer and use it in GitHub Desktop.
CDRS session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cdrs::client::{CDRS, Credentials, Session}; | |
use cdrs::{error as cdrs_error}; | |
use cdrs::authenticators::{Authenticator, PasswordAuthenticator}; | |
use cdrs::compression::Compression; | |
fn main() { | |
let addr = "127.0.0.1:9042"; | |
let authenticator = PasswordAuthenticator::new("user", "password"); | |
let mut session = new_session(addr, authenticator).unwrap(); | |
// ... work with session | |
session.end(); | |
} | |
// Creates new session with server of addres `addr` using provided authenticator | |
fn new_session<A: Authenticator>(addr: &str, authenticator: A) -> cdrs_error::Result<Session<A>> { | |
let cdrs = CDRS::new(addr, authenticator); | |
// establish session without compression so far | |
return cdrs.start(Compression::None); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment