mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-01 11:11:58 +00:00
proxmox-async: clippy fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
0b90f8d802
commit
9539fbde1c
@ -8,6 +8,8 @@ use futures::ready;
|
|||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
use tokio::io::{AsyncRead, ReadBuf};
|
use tokio::io::{AsyncRead, ReadBuf};
|
||||||
|
|
||||||
|
use proxmox_io::vec;
|
||||||
|
|
||||||
/// Wrapper struct to convert an [AsyncRead] into a [Stream]
|
/// Wrapper struct to convert an [AsyncRead] into a [Stream]
|
||||||
pub struct AsyncReaderStream<R: AsyncRead + Unpin> {
|
pub struct AsyncReaderStream<R: AsyncRead + Unpin> {
|
||||||
reader: R,
|
reader: R,
|
||||||
@ -16,19 +18,11 @@ pub struct AsyncReaderStream<R: AsyncRead + Unpin> {
|
|||||||
|
|
||||||
impl<R: AsyncRead + Unpin> AsyncReaderStream<R> {
|
impl<R: AsyncRead + Unpin> AsyncReaderStream<R> {
|
||||||
pub fn new(reader: R) -> Self {
|
pub fn new(reader: R) -> Self {
|
||||||
let mut buffer = Vec::with_capacity(64 * 1024);
|
Self::with_buffer_size(reader, 64 * 1024)
|
||||||
unsafe {
|
|
||||||
buffer.set_len(buffer.capacity());
|
|
||||||
}
|
|
||||||
Self { reader, buffer }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_buffer_size(reader: R, buffer_size: usize) -> Self {
|
pub fn with_buffer_size(reader: R, buffer_size: usize) -> Self {
|
||||||
let mut buffer = Vec::with_capacity(buffer_size);
|
Self { reader, buffer: vec::undefined(buffer_size) }
|
||||||
unsafe {
|
|
||||||
buffer.set_len(buffer.capacity());
|
|
||||||
}
|
|
||||||
Self { reader, buffer }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user