What is the data type of tx in tokio_tungstenite::WebSocketStream?
I am trying to store in for later.
Split the tx & rx from websocket. tx variable will be stored in server type. let (tx, rx) = stream.split();
server.rs
use axum::extract::ws::{Message, WebSocket};
use futures::stream::SplitSink;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio_tungstenite::WebSocketStream;
pub type Server = Arc<Mutex<SplitSink<WebSocketStream<_>, _>>>;
Error:
the placeholder `_` is not allowed within types on item signatures for type aliases
not allowed in type signatures
@jofas Hi
I changed according to you but still getting the placeholder error.
use axum::extract::ws::{Message, WebSocket};
use futures::stream::SplitSink;
use std::sync::Arc;
use tokio::io::AsyncWriteExt;
use tokio::sync::Mutex;
use tokio_tungstenite::WebSocketStream;
pub type Server = Arc<Mutex<SplitSink<WebSocketStream<_>, Message>>>;
Yes, WebSocketStream<_> still has a placeholder. You need to put in the type from which you create the WebSocketStream. Is it tokio::net::TcpStream? Then your type would be WebSocketStream<tokio::net::TcpStream>. If it is a different type than tokio's TCP stream, you'd need to use that instead.
use axum::extract::ws::Message;
use futures::stream::SplitSink;
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio::sync::Mutex;
use tokio_tungstenite::WebSocketStream;
pub type Server = Arc<Mutex<SplitSink<WebSocketStream<TcpStream>, Message>>>;