mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-18 00:27:32 +00:00
tools/websocket: improve traits for WebSocketReader
by dropping unecessary trais for R and impl Sync for ReaderState when R implements Sync Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
521b26d6a2
commit
dfcb50b690
@ -291,7 +291,7 @@ pub struct WebSocketReader<R: AsyncRead> {
|
||||
state: ReaderState<R>,
|
||||
}
|
||||
|
||||
impl<R: AsyncReadExt + Unpin + Send + 'static> WebSocketReader<R> {
|
||||
impl<R: AsyncReadExt> WebSocketReader<R> {
|
||||
pub fn new(reader: R, callback: CallBack) -> WebSocketReader<R> {
|
||||
Self::with_capacity(reader, callback, 4096)
|
||||
}
|
||||
@ -307,13 +307,14 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> WebSocketReader<R> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum ReaderState<R> {
|
||||
NoData,
|
||||
WaitingForData(Pin<Box<dyn Future<Output = Result<(R, ByteBuffer), Error>> + Send + 'static>>),
|
||||
HaveData,
|
||||
}
|
||||
|
||||
unsafe impl<R: Sync> Sync for ReaderState<R> {}
|
||||
|
||||
impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R> {
|
||||
fn poll_read(
|
||||
self: Pin<&mut Self>,
|
||||
|
Loading…
Reference in New Issue
Block a user