Skip to main content

Connection

Struct Connection 

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

Async connection wrapper for TCP/TLS socket This is the async I/O boundary - all socket operations are async

Implementations§

Source§

impl Connection

Source

pub fn new(stream: TcpStream) -> Self

Create a new connection from a TCP stream

Source

pub async fn connect(host: &str, port: u16) -> Result<Self>

Connect to a ClickHouse server with default options

Source

pub async fn connect_with_options( host: &str, port: u16, options: &ConnectionOptions, ) -> Result<Self>

Connect to a ClickHouse server with custom options

Source

pub async fn read_varint(&mut self) -> Result<u64>

Read a varint-encoded u64

Source

pub async fn write_varint(&mut self, value: u64) -> Result<()>

Write a varint-encoded u64

Source

pub async fn read_u8(&mut self) -> Result<u8>

Read a fixed-size value

Source

pub async fn read_u16(&mut self) -> Result<u16>

Read a little-endian u16

Source

pub async fn read_u32(&mut self) -> Result<u32>

Read a little-endian u32

Source

pub async fn read_u64(&mut self) -> Result<u64>

Read a little-endian u64

Source

pub async fn read_i8(&mut self) -> Result<i8>

Read a signed i8

Source

pub async fn read_i16(&mut self) -> Result<i16>

Read a little-endian i16

Source

pub async fn read_i32(&mut self) -> Result<i32>

Read a little-endian i32

Source

pub async fn read_i64(&mut self) -> Result<i64>

Read a little-endian i64

Source

pub async fn write_u8(&mut self, value: u8) -> Result<()>

Write fixed-size values

Source

pub async fn write_u16(&mut self, value: u16) -> Result<()>

Write a little-endian u16

Source

pub async fn write_u32(&mut self, value: u32) -> Result<()>

Write a little-endian u32

Source

pub async fn write_u64(&mut self, value: u64) -> Result<()>

Write a little-endian u64

Source

pub async fn write_u128(&mut self, value: u128) -> Result<()>

Write a little-endian u128

Source

pub async fn write_i8(&mut self, value: i8) -> Result<()>

Write a signed i8

Source

pub async fn write_i16(&mut self, value: i16) -> Result<()>

Write a little-endian i16

Source

pub async fn write_i32(&mut self, value: i32) -> Result<()>

Write a little-endian i32

Source

pub async fn write_i64(&mut self, value: i64) -> Result<()>

Write a little-endian i64

Source

pub async fn read_string(&mut self) -> Result<String>

Read a length-prefixed string

Source

pub async fn write_string(&mut self, s: &str) -> Result<()>

Write a length-prefixed string

Source

pub async fn write_quoted_string(&mut self, s: &str) -> Result<()>

Write a quoted string for query parameters

Source

pub async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Read exact number of bytes into a buffer

Source

pub async fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Read bytes into an existing buffer

Source

pub async fn write_bytes(&mut self, data: &[u8]) -> Result<()>

Write bytes

Source

pub async fn flush(&mut self) -> Result<()>

Flush the write buffer

Source

pub async fn read_packet(&mut self) -> Result<Bytes>

Read a complete packet (length-prefixed data) Returns the packet data without the length prefix

Source

pub async fn write_packet(&mut self, data: &[u8]) -> Result<()>

Write a packet with length prefix

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> 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, 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<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