Struct clickhouse_srv::connection::Connection [−][src]
pub struct Connection { pub buffer: BytesMut, pub session: Arc<dyn ClickHouseSession>, // some fields omitted }
Expand description
Send and receive Packet
values from a remote peer.
When implementing networking protocols, a message on that protocol is
often composed of several smaller messages known as frames. The purpose of
Connection
is to read and write frames on the underlying TcpStream
.
To read frames, the Connection
uses an internal buffer, which is filled
up until there are enough bytes to create a full frame. Once this happens,
the Connection
creates the frame and returns it to the caller.
When sending frames, the frame is first encoded into the write buffer. The contents of the write buffer are then written to the socket.
Fields
buffer: BytesMut
session: Arc<dyn ClickHouseSession>
Implementations
pub fn new(
stream: TcpStream,
session: Arc<dyn ClickHouseSession>,
timezone: String
) -> Result<Connection>
pub fn new(
stream: TcpStream,
session: Arc<dyn ClickHouseSession>,
timezone: String
) -> Result<Connection>
Create a new Connection
, backed by socket
. Read and write buffers
are initialized.
Read a single Packet
value from the underlying stream.
The function waits until it has retrieved enough data to parse a frame.
Any data remaining in the read buffer after the frame has been parsed is
kept there for the next call to read_packet
.
Returns
On success, the received frame is returned. If the TcpStream
is closed in a way that doesn’t break a frame in half, it returns
None
. Otherwise, an error is returned.
pub async fn write_progress(
&mut self,
progress: Progress,
client_revision: u64
) -> Result<()>
Auto Trait Implementations
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection