pub struct Connection { /* private fields */ }Expand description
One broker connection’s protocol state. Owns no socket.
Implementations§
Source§impl Connection
impl Connection
pub fn new(client_id: impl Into<StrBytes>) -> Self
Sourcepub fn in_flight(&self) -> usize
pub fn in_flight(&self) -> usize
How many requests are awaiting responses.
The producer’s in-flight limit is enforced against this: Kafka retains idempotence with up to five in flight, and only because sequence numbers let the broker order them.
Sourcepub fn request<R: Encodable>(
&mut self,
api_key: ApiKey,
version: i16,
req: &R,
) -> Result<Bytes>
pub fn request<R: Encodable>( &mut self, api_key: ApiKey, version: i16, req: &R, ) -> Result<Bytes>
Encode req into a framed, ready-to-write buffer and record it as in
flight.
§Errors
Error::Codec if encoding fails.
Sourcepub fn push_bytes(&mut self, bytes: &[u8])
pub fn push_bytes(&mut self, bytes: &[u8])
Feed bytes from the socket.
Sourcepub fn needed(&self) -> usize
pub fn needed(&self) -> usize
How many more bytes the next response needs. See
FrameDecoder::needed.
Sourcepub fn next_response(&mut self) -> Result<Option<PendingResponse>>
pub fn next_response(&mut self) -> Result<Option<PendingResponse>>
Take the next complete response, matched to its request.
§Errors
Error::Unsolicited if nothing was in flight, Error::Correlation
if the id does not match the oldest in-flight request. Both are fatal
for the connection.
Sourcepub fn decode<R: Decodable>(resp: &PendingResponse) -> Result<R>
pub fn decode<R: Decodable>(resp: &PendingResponse) -> Result<R>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more