Struct Stream

Source
pub struct Stream { /* private fields */ }
Expand description

Abstraction, providing sequential processing of requests.

With streams there is a guarantee that the server instance will not handle the next request in a stream until it has completed the previous one (docs).

§Example

use tarantool_rs::{Connection, Executor, ExecutorExt};

let connection = Connection::builder().build("localhost:3301").await.unwrap();

// This will print 'fast' and then 'slow'
let eval_slow_fut = connection
    .eval("fiber = require('fiber'); fiber.sleep(0.5); return ...;", ("slow", ))
    .inspect(|res| println!("{:?}", res));
let eval_fast_fut = connection
    .eval("return ...;", ("fast", ))
    .inspect(|res| println!("{:?}", res));
let _ = tokio::join!(eval_slow_fut, eval_fast_fut);

// This will print 'slow' and then 'fast', since slow request was created first and have smaller sync
let stream = connection.stream();
let eval_slow_fut = stream
    .eval("fiber = require('fiber'); fiber.sleep(0.5); return ...;", ("slow", ))
    .inspect(|res| println!("{:?}", res));
let eval_fast_fut = stream
    .eval("return ...;", ("fast", ))
    .inspect(|res| println!("{:?}", res));
let _ = tokio::join!(eval_slow_fut, eval_fast_fut);

Trait Implementations§

Source§

impl Clone for Stream

Source§

fn clone(&self) -> Stream

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Executor for Stream

Source§

fn send_encoded_request<'life0, 'async_trait>( &'life0 self, request: EncodedRequest, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send encoded request.
Source§

fn stream(&self) -> Stream

Get new Stream. Read more
Source§

fn transaction_builder(&self) -> TransactionBuilder

Prepare TransactionBuilder, which can be used to override parameters and create Transaction. Read more
Source§

fn transaction<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create Transaction with parameters from builder. Read more
Source§

fn get_cached_sql_statement_id<'life0, 'life1, 'async_trait>( &'life0 self, statement: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

§

impl Freeze for Stream

§

impl !RefUnwindSafe for Stream

§

impl Send for Stream

§

impl Sync for Stream

§

impl Unpin for Stream

§

impl !UnwindSafe for Stream

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<E> ExecutorExt for E
where E: Executor + ?Sized,

Source§

fn send_request<R>( &self, body: R, ) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + '_>>
where R: Request,

Send request, receiving raw response body. Read more
Source§

fn ping<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Ping tarantool instance.
Source§

fn eval<'life0, 'async_trait, A, I>( &'life0 self, expr: I, args: A, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where A: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Evaluate Lua expression. Read more
Source§

fn call<'life0, 'async_trait, A, I>( &'life0 self, function_name: I, args: A, ) -> Pin<Box<dyn Future<Output = Result<CallResponse>> + Send + 'async_trait>>
where A: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Remotely call function in Tarantool. Read more
Source§

fn select<'life0, 'async_trait, T, A>( &'life0 self, space_id: u32, index_id: u32, limit: Option<u32>, offset: Option<u32>, iterator: Option<IteratorType>, keys: A, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: DeserializeOwned + 'async_trait, A: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Select tuples from space.
Source§

fn insert<'life0, 'async_trait, T>( &'life0 self, space_id: u32, tuple: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Insert tuple.
Source§

fn update<'life0, 'async_trait, K, O>( &'life0 self, space_id: u32, index_id: u32, keys: K, ops: O, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
where K: Tuple + Send + 'async_trait, O: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Update tuple.
Source§

fn upsert<'life0, 'async_trait, T, O>( &'life0 self, space_id: u32, tuple: T, ops: O, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
where T: Tuple + Send + 'async_trait, O: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Update or insert tuple.
Source§

fn replace<'life0, 'async_trait, T>( &'life0 self, space_id: u32, tuple: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Insert a tuple into a space. If a tuple with the same primary key already exists, replaces the existing tuple with a new one.
Source§

fn delete<'life0, 'async_trait, T>( &'life0 self, space_id: u32, index_id: u32, keys: T, ) -> Pin<Box<dyn Future<Output = Result<DmoResponse>> + Send + 'async_trait>>
where T: Tuple + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Delete a tuple identified by the primary key.
Source§

fn execute_sql<'life0, 'async_trait, T, I>( &'life0 self, query: I, binds: T, ) -> Pin<Box<dyn Future<Output = Result<SqlResponse>> + Send + 'async_trait>>
where T: Tuple + Send + 'async_trait, I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Perform SQL query.
Source§

fn prepare_sql<'life0, 'async_trait, I>( &'life0 self, query: I, ) -> Pin<Box<dyn Future<Output = Result<PreparedSqlStatement<&Self>>> + Send + 'async_trait>>
where I: AsRef<str> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Prepare SQL statement.
Source§

fn space<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<Space<&Self>>>> + Send + 'async_trait>>
where Self: Sized + Send + Sync + 'async_trait, K: Into<SchemaEntityKey> + Send + 'async_trait, 'life0: 'async_trait,

Find and load space by key. Read more
Source§

fn into_space<'async_trait, K>( self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<Space<Self>>>> + Send + 'async_trait>>
where Self: Sized + Send + Send + 'async_trait, K: Into<SchemaEntityKey> + Send + 'async_trait,

Find and load space by key, moving current executor into Space. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more