pub struct WsClient { /* private fields */ }Expand description
Cliente WebSocket con header de conexión (p. ej. cookie de sesión).
Implementations§
Source§impl WsClient
impl WsClient
Sourcepub async fn connect(
url: &str,
headers: &[(&str, &str)],
cfg: &TransportConfig,
) -> Result<Self, TransportError>
pub async fn connect( url: &str, headers: &[(&str, &str)], cfg: &TransportConfig, ) -> Result<Self, TransportError>
Conecta a url con los headers dados (nombre, valor).
Sourcepub async fn connect_con_reintentos(
url: &str,
headers: Vec<(String, String)>,
cfg: TransportConfig,
) -> Result<Self, TransportError>
pub async fn connect_con_reintentos( url: &str, headers: Vec<(String, String)>, cfg: TransportConfig, ) -> Result<Self, TransportError>
Conecta con reintentos (backoff de la configuración).
pub fn url(&self) -> &str
Sourcepub async fn enviar(
&mut self,
name: &str,
msg: &Value,
request_id: &str,
) -> Result<(), TransportError>
pub async fn enviar( &mut self, name: &str, msg: &Value, request_id: &str, ) -> Result<(), TransportError>
Envía un mensaje con el envelope {name, msg, request_id}.
Sourcepub async fn enviar_sin_id(
&mut self,
name: &str,
msg: &Value,
) -> Result<(), TransportError>
pub async fn enviar_sin_id( &mut self, name: &str, msg: &Value, ) -> Result<(), TransportError>
Envía mensaje sin request_id (respuestas del servidor no lo llevan).
Sourcepub async fn siguiente(&mut self) -> Option<Result<WsFrame, TransportError>>
pub async fn siguiente(&mut self) -> Option<Result<WsFrame, TransportError>>
Siguiente mensaje ya parseado. None cuando el socket cierra.
Ping/Pong se manejan aquí: el socket nunca ve frames de control.
Sourcepub async fn cerrar(&mut self) -> Result<(), TransportError>
pub async fn cerrar(&mut self) -> Result<(), TransportError>
Cierra el socket limpiamente.
Auto Trait Implementations§
impl !Freeze for WsClient
impl !RefUnwindSafe for WsClient
impl !UnwindSafe for WsClient
impl Forget for WsClient
impl Send for WsClient
impl Sync for WsClient
impl Unpin for WsClient
impl UnsafeUnpin for WsClient
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