RawData, clippy
This commit is contained in:
parent
5d39e227b6
commit
e34287df9e
4 changed files with 56 additions and 3 deletions
|
@ -18,3 +18,6 @@ dasp_sample = "0.11.0"
|
|||
rayon = "1.10.0"
|
||||
dirs = "5.0.1"
|
||||
rfd = "0.14.1"
|
||||
derive-new = "0.6.0"
|
||||
infer = "0.16.0"
|
||||
indicatif = { version = "0.17.8", features = ["rayon"] }
|
||||
|
|
|
@ -19,5 +19,6 @@ dasp_sample = { workspace = true }
|
|||
rayon = { workspace = true }
|
||||
dirs = { workspace = true }
|
||||
rfd = { workspace = true }
|
||||
derive-new = "0.6.0"
|
||||
indicatif = { version = "0.17.8", features = ["rayon"] }
|
||||
derive-new = { workspace = true }
|
||||
infer = { workspace = true }
|
||||
indicatif = { workspace = true }
|
||||
|
|
|
@ -81,7 +81,7 @@ fn main() -> Result<()> {
|
|||
"[{eta}] {bar:40.green/red} {pos}/{len} pixels",
|
||||
)?)
|
||||
.map(|px: &[u8]| (px[2] as i32) | ((px[1] as i32) << 8) | ((px[0] as i32) << 16))
|
||||
.map(|px| U24::new_unchecked(px))
|
||||
.map(U24::new_unchecked)
|
||||
.map(|x| uparc(x.to_sample()))
|
||||
.flat_map(|sample: f32| {
|
||||
let rgb: U24 = sample.to_sample();
|
||||
|
|
|
@ -1 +1,50 @@
|
|||
use std::{borrow::Cow, ops::Deref};
|
||||
|
||||
type Bytes<'a> = Cow<'a, [u8]>;
|
||||
|
||||
pub trait Metadata {}
|
||||
|
||||
pub struct RawData<'a, M: Metadata> {
|
||||
pub(crate) data: Bytes<'a>,
|
||||
pub(crate) metadata: M,
|
||||
}
|
||||
|
||||
impl<'a, M> RawData<'a, M>
|
||||
where
|
||||
M: Metadata,
|
||||
{
|
||||
fn metadata(&self) -> &M {
|
||||
&self.metadata
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M> Deref for RawData<'a, M>
|
||||
where
|
||||
M: Metadata,
|
||||
{
|
||||
type Target = Bytes<'a>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M> From<RawData<'a, M>> for Vec<u8>
|
||||
where
|
||||
M: Metadata,
|
||||
{
|
||||
fn from(value: RawData<'a, M>) -> Self {
|
||||
value.data.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M> Clone for RawData<'a, M>
|
||||
where
|
||||
M: Metadata + Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
data: self.data.clone(),
|
||||
metadata: self.metadata().clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue