Skip to main content

limitless/ws/
mod.rs

1pub mod channel;
2pub mod client;
3pub mod stream;
4pub use channel::*;
5pub use stream::*;
6
7use tokio::time::Duration;
8
9use crate::prelude::*;
10use tokio::sync::mpsc;
11
12/// Interval at which the WebSocket event loop sends a ping to keep the
13/// connection alive (the Limitless WS uses Socket.IO-level pings internally,
14/// but we maintain our own keep-alive on the raw WebSocket).
15pub(crate) const PING_INTERVAL: Duration = Duration::from_secs(25);
16
17/// Helper: send an item through an unbounded channel, mapping the error
18/// to `LimitlessError`.
19#[allow(dead_code)]
20pub(crate) fn send_or_err<T>(
21    sender: &mpsc::UnboundedSender<T>,
22    item: T,
23) -> Result<(), LimitlessError> {
24    sender
25        .send(item)
26        .map_err(|e| LimitlessError::ChannelSendError {
27            underlying: e.to_string(),
28        })
29}