Skip to main content

BorrowedReader

Struct BorrowedReader 

Source
pub struct BorrowedReader<'a> { /* private fields */ }
Expand description

A query Reader borrowed from a QuestDb pool.

Egress companion to BorrowedSender. Derefs to Reader, so the usual prepare / execute cursor flow works unchanged. On Drop the reader is returned to the reader pool, unless its transport has been torn down (or Self::drop_on_return was called), in which case it is dropped and the next borrow opens a fresh one.

BorrowedReader is not Send or Sync: the borrowed connection belongs to the borrowing thread for the duration of the borrow.

Implementations§

Source§

impl<'a> BorrowedReader<'a>

Source

pub fn drop_on_return(&mut self)

Force this borrowed reader to be dropped (not recycled) when the borrow ends.

Use normal Drop for healthy readers: the return path already retires readers whose transport was torn down, or whose pool has been closed. Call this after abandoning work or handling an error where the next borrower must not inherit this connection.

Methods from Deref<Target = Reader>§

Source

pub fn current_addr(&self) -> &Endpoint

The endpoint this connection is currently bound to. Borrowed from the configured address list, so the borrow lives as long as &self. Stable across connect-string reorderings, unlike the (deliberately not exposed) underlying address-list index.

Source

pub fn bytes_received(&self) -> u64

Total wire bytes (frame header + payload) read off the transport since this connection was opened. Useful for benchmarking the effective throughput a query produces.

Source

pub fn transport_torn_down(&self) -> bool

true when the underlying transport has been torn down (mid-stream cursor abandonment, fatal socket error, role-mismatch failover that couldn’t find a replacement). Pool return paths should treat such a reader as must-close.

Source

pub fn credit_granted_total(&self) -> u64

Total bytes granted to the server via CREDIT (0x15) frames since this connection was opened. Useful for verifying that flow-control replenishment behaves as expected — in particular, that Cursor::cancel() doesn’t continue topping up the server’s budget while draining frames it’s about to discard.

Source

pub fn read_ns(&self) -> u64

Diagnostic accumulator (nanoseconds): time spent in transport.read_frame(). Saturates at u64::MAX (~584 years). Reset to zero by Reader::reset_timing.

Source

pub fn decode_ns(&self) -> u64

Diagnostic accumulator (nanoseconds): time spent in decode_frame(). Saturates at u64::MAX. Reset to zero by Reader::reset_timing.

Source

pub fn reset_timing(&self)

Reset both read_ns and decode_ns accumulators to zero.

Source

pub fn stats(&self) -> &Arc<ReaderStats>

Borrow the shared diagnostic counters. The FFI clones this at qwp_reader_from_conf time so its stat getters can read the counters without touching the UnsafeCell<Reader> that holds this Reader — eliminating the aliasing question of “what happens when a stat getter synthesises a &Reader while a laundered &mut Reader is in flight.”

Source

pub fn server_info(&self) -> Option<&ServerInfo>

SERVER_INFO (0x18) captured at connect time. None only while a reconnect is in flight; the single QWP version always supplies it.

Source

pub fn server_version(&self) -> Result<u8>

Negotiated QWP version this connection is using. Returns SocketError when the Reader is poisoned after a failed mid-query failover.

Source

pub fn symbol_dict(&self) -> &SymbolDict

Connection-scoped symbol dictionary.

Source

pub fn prepare<S: Into<String>>(&mut self, sql: S) -> ReaderQuery<'_>

Begin building a parametrised query. The returned ReaderQuery exclusively borrows the reader; only one in-flight cursor at a time. Append binds in placeholder order, then call .execute().

Source

pub fn execute<S: Into<String>>(&mut self, sql: S) -> Result<Cursor<'_>>

Execute a SQL statement with no binds and return a streaming cursor. Convenience for self.prepare(sql).execute().

Trait Implementations§

Source§

impl Debug for BorrowedReader<'_>

Available on crate feature _egress only.
Source§

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

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

impl Deref for BorrowedReader<'_>

Available on crate feature _egress only.
Source§

type Target = Reader

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for BorrowedReader<'_>

Available on crate feature _egress only.
Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for BorrowedReader<'_>

Available on crate feature _egress only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BorrowedReader<'a>

§

impl<'a> !Send for BorrowedReader<'a>

§

impl<'a> !Sync for BorrowedReader<'a>

§

impl<'a> !UnwindSafe for BorrowedReader<'a>

§

impl<'a> Freeze for BorrowedReader<'a>

§

impl<'a> Unpin for BorrowedReader<'a>

§

impl<'a> UnsafeUnpin for BorrowedReader<'a>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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