mirror of
https://git.proxmox.com/git/proxmox
synced 2025-07-11 10:30:11 +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>,
|
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> {
|
pub fn new(reader: R, callback: CallBack) -> WebSocketReader<R> {
|
||||||
Self::with_capacity(reader, callback, 4096)
|
Self::with_capacity(reader, callback, 4096)
|
||||||
}
|
}
|
||||||
@ -307,13 +307,14 @@ impl<R: AsyncReadExt + Unpin + Send + 'static> WebSocketReader<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum ReaderState<R> {
|
enum ReaderState<R> {
|
||||||
NoData,
|
NoData,
|
||||||
WaitingForData(Pin<Box<dyn Future<Output = Result<(R, ByteBuffer), Error>> + Send + 'static>>),
|
WaitingForData(Pin<Box<dyn Future<Output = Result<(R, ByteBuffer), Error>> + Send + 'static>>),
|
||||||
HaveData,
|
HaveData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl<R: Sync> Sync for ReaderState<R> {}
|
||||||
|
|
||||||
impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R> {
|
impl<R: AsyncReadExt + Unpin + Send + 'static> AsyncRead for WebSocketReader<R> {
|
||||||
fn poll_read(
|
fn poll_read(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
|
Loading…
Reference in New Issue
Block a user