mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* rename frontend to web and update contributing guide * rename this time * fix build * restructure rust code * update documentation * update descriptions * Update CONTRIBUTING.md Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com> --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
32 lines
851 B
Rust
32 lines
851 B
Rust
use std::task::Poll;
|
|
|
|
use tokio::io::{AsyncRead, ReadBuf};
|
|
|
|
#[pin_project::pin_project]
|
|
pub struct ByteReplacementReader<R> {
|
|
pub replace: u8,
|
|
pub with: u8,
|
|
#[pin]
|
|
pub inner: R,
|
|
}
|
|
impl<R: AsyncRead> AsyncRead for ByteReplacementReader<R> {
|
|
fn poll_read(
|
|
self: std::pin::Pin<&mut Self>,
|
|
cx: &mut std::task::Context<'_>,
|
|
buf: &mut ReadBuf<'_>,
|
|
) -> std::task::Poll<std::io::Result<()>> {
|
|
let this = self.project();
|
|
match this.inner.poll_read(cx, buf) {
|
|
Poll::Ready(Ok(())) => {
|
|
for idx in 0..buf.filled().len() {
|
|
if buf.filled()[idx] == *this.replace {
|
|
buf.filled_mut()[idx] = *this.with;
|
|
}
|
|
}
|
|
Poll::Ready(Ok(()))
|
|
}
|
|
a => a,
|
|
}
|
|
}
|
|
}
|