pub struct Config { /* private fields */ }Expand description
Configuration for a Skytable connection
Implementations§
Source§impl Config
impl Config
Sourcepub fn new_default(username: &str, password: &str) -> Self
pub fn new_default(username: &str, password: &str) -> Self
Create a new Config using the default connection settings and using the provided username and password
Examples found in repository?
More examples
examples/dynamic_lists_advanced.rs (line 64)
63fn main() {
64 let mut db = Config::new_default("root", "password12345678")
65 .connect()
66 .unwrap();
67 let data_from_api = get_data_from_api();
68 db.query_parse::<()>(&skytable::query!(
69 "insert into myapp.mydb { username: ?, password: ?, data: ? }",
70 &data_from_api
71 ))
72 .unwrap();
73 let fetched_user: User = db
74 .query_parse(&skytable::query!(
75 "select * from myapp.mydb where username = ?",
76 "sayan"
77 ))
78 .unwrap();
79 assert_eq!(data_from_api, fetched_user);
80}examples/custom_types.rs (line 44)
43fn main() {
44 let mut db = Config::new_default("username", "password")
45 .connect()
46 .unwrap();
47
48 // set up schema
49 // create space
50 db.query_parse::<()>(&query!("create space myspace"))
51 .unwrap();
52 // create model
53 db.query_parse::<()>(&query!(
54 "create model myspace.mymodel(username: string, password: string, followers: uint64, null email: string)"
55 ))
56 .unwrap();
57
58 // insert data
59 let our_user = User::new("myuser".into(), "pass123".into(), 0, None);
60 db.query_parse::<()>(&query!(
61 "insert into myspace.mymodel(?, ?, ?, ?)",
62 our_user.clone()
63 ))
64 .unwrap();
65
66 // select data
67 let ret_user: User = db
68 .query_parse(&query!(
69 "select * from myspace.mymodel WHERE username = ?",
70 &our_user.username
71 ))
72 .unwrap();
73
74 assert_eq!(our_user, ret_user);
75}examples/dynamic_lists_simple.rs (line 20)
19fn main() {
20 let mut db = Config::new_default("root", "password12345678")
21 .connect()
22 .unwrap();
23 let data_from_api = get_list_data_from_api();
24 let q = skytable::query!(
25 "insert into myapp.mydb { username: ?, password: ?, data: ? }",
26 "sayan",
27 "ulw06afuMCAg+1gh2lh1Y9xTIr/dUv2vqGLeZ39cVrE=",
28 QList::new(&data_from_api)
29 );
30 db.query_parse::<()>(&q).unwrap(); // expect this data to be inserted correctly
31 // now fetch this data
32 let (username, password, data): (String, String, RList<String>) = db
33 .query_parse(&skytable::query!(
34 "select * from myapp.mydb where username = ?",
35 "sayan"
36 ))
37 .unwrap();
38 assert_eq!(username, "sayan");
39 assert_eq!(password, "ulw06afuMCAg+1gh2lh1Y9xTIr/dUv2vqGLeZ39cVrE=");
40 assert_eq!(data.into_values(), data_from_api);
41}examples/simple.rs (line 11)
10fn main() {
11 let mut db = Config::new_default("username", "password")
12 .connect()
13 .unwrap();
14
15 // set up schema
16 // create space
17 db.query_parse::<()>(&query!("create space myspace"))
18 .unwrap();
19 // create model
20 db.query_parse::<()>(&query!(
21 "create model myspace.mymodel(username: string, password: string, followers: uint64)"
22 ))
23 .unwrap();
24
25 // manipulate data
26
27 let (form_username, form_pass) = dummy_web_fetch_username_password();
28 // insert some data
29 db.query_parse::<()>(&query!(
30 "insert into myspace.mymodel(?, ?, ?)",
31 &form_username,
32 form_pass,
33 100_000_000u64
34 ))
35 .unwrap();
36
37 // get it back
38 let (password, followers): (String, u64) = db
39 .query_parse(&query!(
40 "select password, followers FROM myspace.mymodel WHERE username = ?",
41 &form_username
42 ))
43 .unwrap();
44 assert_eq!(password, "rick123", "password changed!");
45 // send to our client
46 dummy_respond_to_request(followers);
47
48 // update followers to account for huge numbers who were angry after being rickrolled
49 db.query_parse::<()>(&query!(
50 "update myspace.mymodel SET followers -= ? WHERE username = ?",
51 50_000_000u64,
52 &form_username
53 ))
54 .unwrap();
55
56 // alright, everyone is tired from being rickrolled so we'll have to ban rick's account
57 db.query_parse::<()>(&query!(
58 "delete from myspace.mymodel where username = ?",
59 &form_username
60 ))
61 .unwrap();
62}Source§impl Config
impl Config
Sourcepub async fn connect_async(&self) -> ClientResult<ConnectionAsync>
pub async fn connect_async(&self) -> ClientResult<ConnectionAsync>
Establish an async connection to the database using the current configuration
Sourcepub async fn connect_tls_async(
&self,
cert: &str,
) -> ClientResult<ConnectionTlsAsync>
pub async fn connect_tls_async( &self, cert: &str, ) -> ClientResult<ConnectionTlsAsync>
Establish an async TLS connection to the database using the current configuration. Pass the certificate in PEM format.
Source§impl Config
impl Config
Sourcepub fn connect(&self) -> ClientResult<Connection>
pub fn connect(&self) -> ClientResult<Connection>
Establish a connection to the database using the current configuration
Examples found in repository?
More examples
examples/dynamic_lists_advanced.rs (line 65)
63fn main() {
64 let mut db = Config::new_default("root", "password12345678")
65 .connect()
66 .unwrap();
67 let data_from_api = get_data_from_api();
68 db.query_parse::<()>(&skytable::query!(
69 "insert into myapp.mydb { username: ?, password: ?, data: ? }",
70 &data_from_api
71 ))
72 .unwrap();
73 let fetched_user: User = db
74 .query_parse(&skytable::query!(
75 "select * from myapp.mydb where username = ?",
76 "sayan"
77 ))
78 .unwrap();
79 assert_eq!(data_from_api, fetched_user);
80}examples/custom_types.rs (line 45)
43fn main() {
44 let mut db = Config::new_default("username", "password")
45 .connect()
46 .unwrap();
47
48 // set up schema
49 // create space
50 db.query_parse::<()>(&query!("create space myspace"))
51 .unwrap();
52 // create model
53 db.query_parse::<()>(&query!(
54 "create model myspace.mymodel(username: string, password: string, followers: uint64, null email: string)"
55 ))
56 .unwrap();
57
58 // insert data
59 let our_user = User::new("myuser".into(), "pass123".into(), 0, None);
60 db.query_parse::<()>(&query!(
61 "insert into myspace.mymodel(?, ?, ?, ?)",
62 our_user.clone()
63 ))
64 .unwrap();
65
66 // select data
67 let ret_user: User = db
68 .query_parse(&query!(
69 "select * from myspace.mymodel WHERE username = ?",
70 &our_user.username
71 ))
72 .unwrap();
73
74 assert_eq!(our_user, ret_user);
75}examples/dynamic_lists_simple.rs (line 21)
19fn main() {
20 let mut db = Config::new_default("root", "password12345678")
21 .connect()
22 .unwrap();
23 let data_from_api = get_list_data_from_api();
24 let q = skytable::query!(
25 "insert into myapp.mydb { username: ?, password: ?, data: ? }",
26 "sayan",
27 "ulw06afuMCAg+1gh2lh1Y9xTIr/dUv2vqGLeZ39cVrE=",
28 QList::new(&data_from_api)
29 );
30 db.query_parse::<()>(&q).unwrap(); // expect this data to be inserted correctly
31 // now fetch this data
32 let (username, password, data): (String, String, RList<String>) = db
33 .query_parse(&skytable::query!(
34 "select * from myapp.mydb where username = ?",
35 "sayan"
36 ))
37 .unwrap();
38 assert_eq!(username, "sayan");
39 assert_eq!(password, "ulw06afuMCAg+1gh2lh1Y9xTIr/dUv2vqGLeZ39cVrE=");
40 assert_eq!(data.into_values(), data_from_api);
41}examples/simple.rs (line 12)
10fn main() {
11 let mut db = Config::new_default("username", "password")
12 .connect()
13 .unwrap();
14
15 // set up schema
16 // create space
17 db.query_parse::<()>(&query!("create space myspace"))
18 .unwrap();
19 // create model
20 db.query_parse::<()>(&query!(
21 "create model myspace.mymodel(username: string, password: string, followers: uint64)"
22 ))
23 .unwrap();
24
25 // manipulate data
26
27 let (form_username, form_pass) = dummy_web_fetch_username_password();
28 // insert some data
29 db.query_parse::<()>(&query!(
30 "insert into myspace.mymodel(?, ?, ?)",
31 &form_username,
32 form_pass,
33 100_000_000u64
34 ))
35 .unwrap();
36
37 // get it back
38 let (password, followers): (String, u64) = db
39 .query_parse(&query!(
40 "select password, followers FROM myspace.mymodel WHERE username = ?",
41 &form_username
42 ))
43 .unwrap();
44 assert_eq!(password, "rick123", "password changed!");
45 // send to our client
46 dummy_respond_to_request(followers);
47
48 // update followers to account for huge numbers who were angry after being rickrolled
49 db.query_parse::<()>(&query!(
50 "update myspace.mymodel SET followers -= ? WHERE username = ?",
51 50_000_000u64,
52 &form_username
53 ))
54 .unwrap();
55
56 // alright, everyone is tired from being rickrolled so we'll have to ban rick's account
57 db.query_parse::<()>(&query!(
58 "delete from myspace.mymodel where username = ?",
59 &form_username
60 ))
61 .unwrap();
62}Sourcepub fn connect_tls(&self, cert: &str) -> ClientResult<ConnectionTls>
pub fn connect_tls(&self, cert: &str) -> ClientResult<ConnectionTls>
Establish a TLS connection to the database using the current configuration. Pass the certificate in PEM format.
Trait Implementations§
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more