Connection

Struct Connection 

Source
pub struct Connection(/* private fields */);
Expand description

Represents a connection to a remote or embedded KDB instance, which can be used to send and query data on that instance.

Implementations§

Source§

impl Connection

Source

pub fn connect( hostname: &str, port: u16, credentials: &str, timeout: Option<Duration>, ) -> Result<Self, ConnectionError>

[non-embedded only] Connect to a remote instance of KDB.

Examples found in repository?
examples/publishing.rs (line 5)
4fn main() {
5    let conn = Connection::connect("127.0.0.1", 4200, "", None).unwrap();
6    let l = list![i32; 1, 2, 3];
7    if let Err(err) = conn.publish("upd", symbol("some_topic"), l) {
8        println!("Publishing failed: {}", err);
9    }
10    println!("Publish succeeded! Probably.");
11}
More examples
Hide additional examples
examples/connecting_to_kdb.rs (line 4)
3fn main() -> Result<(), ConnectionError> {
4    let conn = Connection::connect("127.0.0.1", 4200, "", None)?;
5    let result = cast!(conn.eval("2+2").unwrap(); Atom<i64>);
6    println!("{}", result.value());
7
8    //Returning a list of symbols
9    let result = cast!(conn.eval("`a`b`c").unwrap(); List<Symbol>);
10    println!("{:?}", &result[0..]);
11
12    Ok(())
13}
Source

pub fn new() -> Self

[embedded only] Connect to an embedded KDB instance.

Source

pub fn publish( &self, callback: &str, topic: impl Into<KBox<Any>>, object: impl Into<KBox<Any>>, ) -> Result<(), Error>

[non-embedded only] Publish a value asynchronously to KDB.

Examples found in repository?
examples/publishing.rs (line 7)
4fn main() {
5    let conn = Connection::connect("127.0.0.1", 4200, "", None).unwrap();
6    let l = list![i32; 1, 2, 3];
7    if let Err(err) = conn.publish("upd", symbol("some_topic"), l) {
8        println!("Publishing failed: {}", err);
9    }
10    println!("Publish succeeded! Probably.");
11}
Source

pub fn eval(&self, query: &str) -> Result<KBox<Any>, Error>

Evaluate a q expression with no parameters and return a result.

Examples found in repository?
examples/connecting_to_kdb.rs (line 5)
3fn main() -> Result<(), ConnectionError> {
4    let conn = Connection::connect("127.0.0.1", 4200, "", None)?;
5    let result = cast!(conn.eval("2+2").unwrap(); Atom<i64>);
6    println!("{}", result.value());
7
8    //Returning a list of symbols
9    let result = cast!(conn.eval("`a`b`c").unwrap(); List<Symbol>);
10    println!("{:?}", &result[0..]);
11
12    Ok(())
13}
Source

pub fn eval_1( &self, function: &str, param: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with a single parameter and return the result.

Source

pub fn eval_2( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with two parameters and return the result.

Source

pub fn eval_3( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with three parameters and return the result.

Source

pub fn eval_4( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, param_4: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with four parameters and return the result.

Source

pub fn eval_5( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, param_4: impl Into<KBox<Any>>, param_5: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with five parameters and return the result.

Source

pub fn eval_6( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, param_4: impl Into<KBox<Any>>, param_5: impl Into<KBox<Any>>, param_6: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with six parameters and return the result.

Source

pub fn eval_7( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, param_4: impl Into<KBox<Any>>, param_5: impl Into<KBox<Any>>, param_6: impl Into<KBox<Any>>, param_7: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

Evaluate a q function with seven parameters and return the result.

Source

pub fn eval_8( &self, function: &str, param: impl Into<KBox<Any>>, param_2: impl Into<KBox<Any>>, param_3: impl Into<KBox<Any>>, param_4: impl Into<KBox<Any>>, param_5: impl Into<KBox<Any>>, param_6: impl Into<KBox<Any>>, param_7: impl Into<KBox<Any>>, param_8: impl Into<KBox<Any>>, ) -> Result<KBox<Any>, Error>

See above and add one parameter.

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.