Skip to main content

ActiveConnection

Struct ActiveConnection 

Source
pub struct ActiveConnection {
    pub id: u64,
    pub stream: TcpStream,
    pub host: String,
    pub last_used: Instant,
}
Expand description

活动连接信息

Fields§

§id: u64

唯一连接 ID

§stream: TcpStream

TCP 流

§host: String

目标主机

§last_used: Instant

最后使用时间

Implementations§

Source§

impl ActiveConnection

Source

pub fn is_valid(&self) -> bool

检查连接是否仍然有效

Source

pub fn touch(&mut self)

更新最后使用时间

Source§

impl ActiveConnection

Source

pub async fn read_with_timeout( &mut self, buf: &mut [u8], read_timeout: Duration, ) -> Result<usize>

异步读取数据(带超时控制)

从 TCP 流中读取数据到缓冲区,受 read_timeout 限制。 用于读取 HTTP 响应头和响应体。

Source

pub async fn write_with_timeout( &mut self, buf: &[u8], write_timeout: Duration, ) -> Result<usize>

异步写入数据(带超时控制)

将数据写入 TCP 流,受 write_timeout 限制。 用于发送 HTTP 请求头和请求体。

Source

pub async fn flush_with_timeout( &mut self, write_timeout: Duration, ) -> Result<()>

刷新写缓冲区(带超时控制)

Source

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

关闭连接(双向关闭)

Source

pub fn peer_addr(&self) -> Result<SocketAddr>

获取对等端地址

Source

pub fn local_addr(&self) -> Result<SocketAddr>

获取本地地址

Trait Implementations§

Source§

impl Debug for ActiveConnection

Source§

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

Formats the value using the given formatter. Read more

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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

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