pub struct Connection { /* private fields */ }Expand description
TCP连接管理器
Implementations§
Source§impl Connection
 
impl Connection
Sourcepub async fn new<A: ToSocketAddrs + Display>(
    addr: A,
    identify_config: Option<IdentifyConfig>,
    auth_secret: Option<String>,
    read_timeout: Duration,
    write_timeout: Duration,
) -> Result<Self>
 
pub async fn new<A: ToSocketAddrs + Display>( addr: A, identify_config: Option<IdentifyConfig>, auth_secret: Option<String>, read_timeout: Duration, write_timeout: Duration, ) -> Result<Self>
创建新的连接
Sourcepub async fn connect_with_retry(
    addr: &str,
    timeout_duration: Duration,
    _read_timeout: Duration,
    _write_timeout: Duration,
) -> Result<TcpStream>
 
pub async fn connect_with_retry( addr: &str, timeout_duration: Duration, _read_timeout: Duration, _write_timeout: Duration, ) -> Result<TcpStream>
使用重试机制连接到NSQ服务器
Sourcepub async fn send_command(&self, command: Command) -> Result<()>
 
pub async fn send_command(&self, command: Command) -> Result<()>
发送命令到NSQ服务器
Sourcepub async fn read_frame(&self) -> Result<Frame>
 
pub async fn read_frame(&self) -> Result<Frame>
读取下一个NSQ帧
Sourcepub async fn handle_heartbeat(&self) -> Result<()>
 
pub async fn handle_heartbeat(&self) -> Result<()>
处理心跳帧
Sourcepub async fn read_message(&self) -> Result<Option<Message>>
 
pub async fn read_message(&self) -> Result<Option<Message>>
读取消息 - 参考Go客户端中的readLoop实现
pub async fn write_all(&self, buf: &[u8]) -> Result<()>
pub async fn read_exact(&self, buf: &mut [u8]) -> Result<()>
pub async fn write_command( &self, name: &str, body: Option<&[u8]>, params: &[&str], ) -> Result<()>
pub async fn close(&self) -> Result<()>
Trait Implementations§
Source§impl Debug for Connection
 
impl Debug for Connection
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin 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