pub struct WsConnection {
pub ws_sender: WsSender,
pub ws_receiver: WsReceiver,
pub msg_id: u64,
pub connecting: bool,
pub asking_size_max: u64,
pub available: bool,
pub name: String,
pub auto_loading: bool,
pub waiting_for_response: bool,
}Expand description
WsConnection struct
Fields§
§ws_sender: WsSenderWebSocket sender
ws_receiver: WsReceiverWebSocket receiver
msg_id: u64Message ID
connecting: boolConnecting flag
asking_size_max: u64Asking size max
available: boolAvailable flag
name: StringName of the receiver
auto_loading: boolAuto-loading flag - when true, automatically requests more data
waiting_for_response: boolWaiting for response flag - true when a request has been sent and we’re waiting for the response
Implementations§
Source§impl WsConnection
impl WsConnection
Sourcepub fn connect(
url: &str,
wakeup: impl Fn() + Send + Sync + 'static,
) -> Result<(WsSender, WsReceiver), String>
pub fn connect( url: &str, wakeup: impl Fn() + Send + Sync + 'static, ) -> Result<(WsSender, WsReceiver), String>
Connect to a WebSocket
§Errors
Return an error as String if the connection failed - see [ewebsock::connect_with_wakeup] for more details
Sourcepub fn close_impl(&mut self) -> Result<(), TramexError>
pub fn close_impl(&mut self) -> Result<(), TramexError>
Try to close the ws
§Errors
Return an error if its fail see [ewebsock::WsSender::close] for more details
Source§impl WsConnection
impl WsConnection
Sourcepub fn should_request_more(&self) -> bool
pub fn should_request_more(&self) -> bool
Check if we should send a new request Returns true if auto-loading is enabled and not currently waiting for a response The server-side timeout and allow_empty=false handle the timing automatically
Trait Implementations§
Source§impl Debug for WsConnection
impl Debug for WsConnection
Source§impl Drop for WsConnection
impl Drop for WsConnection
Source§impl InterfaceTrait for WsConnection
impl InterfaceTrait for WsConnection
Source§fn get_more_data(
&mut self,
layer_list: Layers,
_data: &mut Data,
) -> Result<(), Vec<TramexError>>
fn get_more_data( &mut self, layer_list: Layers, _data: &mut Data, ) -> Result<(), Vec<TramexError>>
Get more data Read more
Source§fn supports_preloading(&self) -> bool
fn supports_preloading(&self) -> bool
Check if this interface supports preloading (e.g., file can preload, websocket cannot)
Source§fn get_total_event_count(&self) -> Option<usize>
fn get_total_event_count(&self) -> Option<usize>
Get total event count if known (Some for files, None for websockets)
Source§fn is_fully_read(&self) -> bool
fn is_fully_read(&self) -> bool
Check if all data has been read
Auto Trait Implementations§
impl Freeze for WsConnection
impl RefUnwindSafe for WsConnection
impl Send for WsConnection
impl !Sync for WsConnection
impl Unpin for WsConnection
impl UnwindSafe for WsConnection
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