remove Sized requirement
This commit is contained in:
parent
2a93d99841
commit
130a75d0ca
9 changed files with 10 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bingus"
|
name = "bingus"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
|
|
|
@ -19,10 +19,7 @@ impl TryFromDataBytes for Bytes {
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
_: Self::Format,
|
_: Self::Format,
|
||||||
_: crate::Crop,
|
_: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,7 @@ impl TryFromDataBytes for PdfDocument {
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
_format: Self::Format,
|
_format: Self::Format,
|
||||||
_crop: crate::Crop,
|
_crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
let mut warnings = Vec::new();
|
let mut warnings = Vec::new();
|
||||||
let result = PdfDocument::parse(
|
let result = PdfDocument::parse(
|
||||||
&bytes,
|
&bytes,
|
||||||
|
|
|
@ -26,10 +26,7 @@ impl TryFromDataBytes for ShivaDocument {
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
format: Self::Format,
|
format: Self::Format,
|
||||||
_crop: crate::Crop,
|
_crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
Ok(ShivaDocument::new(
|
Ok(ShivaDocument::new(
|
||||||
Document::parse(&Bytes::from(bytes), format.input_format)?,
|
Document::parse(&Bytes::from(bytes), format.input_format)?,
|
||||||
format.output_format,
|
format.output_format,
|
||||||
|
|
|
@ -13,10 +13,7 @@ impl TryFromDataBytes for Font {
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
_format: Self::Format,
|
_format: Self::Format,
|
||||||
_crop: crate::Crop,
|
_crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
Self::from_bytes(Arc::new(bytes), 0)
|
Self::from_bytes(Arc::new(bytes), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,7 @@ where
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
format: Self::Format,
|
format: Self::Format,
|
||||||
crop: crate::Crop,
|
crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
ImageBuffer::from_raw(
|
ImageBuffer::from_raw(
|
||||||
format.width,
|
format.width,
|
||||||
format.height,
|
format.height,
|
||||||
|
@ -213,10 +210,7 @@ impl TryFromDataBytes for DynamicImage {
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
format: Self::Format,
|
format: Self::Format,
|
||||||
crop: crate::Crop,
|
crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
match format.1 {
|
match format.1 {
|
||||||
ColorType::L8 => Ok(DynamicImage::ImageLuma8(ImageBuffer::from_data_bytes(
|
ColorType::L8 => Ok(DynamicImage::ImageLuma8(ImageBuffer::from_data_bytes(
|
||||||
bytes, format.0, crop,
|
bytes, format.0, crop,
|
||||||
|
|
|
@ -357,10 +357,7 @@ where
|
||||||
T: TryFromDataBytes<Error = Infallible, Format = F>,
|
T: TryFromDataBytes<Error = Infallible, Format = F>,
|
||||||
{
|
{
|
||||||
type Format = <T as TryFromDataBytes>::Format;
|
type Format = <T as TryFromDataBytes>::Format;
|
||||||
fn from_data_bytes(bytes: Bytes, format: Self::Format, crop: Crop) -> Self
|
fn from_data_bytes(bytes: Bytes, format: Self::Format, crop: Crop) -> Self {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
T::try_from_data_bytes(bytes, format, crop).unwrap_or_else(|_| unreachable!())
|
T::try_from_data_bytes(bytes, format, crop).unwrap_or_else(|_| unreachable!())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,7 @@ where
|
||||||
bytes: crate::Bytes,
|
bytes: crate::Bytes,
|
||||||
_format: Self::Format,
|
_format: Self::Format,
|
||||||
crop: crate::Crop,
|
crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
Ok(match crop {
|
Ok(match crop {
|
||||||
crate::Crop::End => bytes
|
crate::Crop::End => bytes
|
||||||
.chunks_exact(T::zero().to_ne_bytes().as_ref().len())
|
.chunks_exact(T::zero().to_ne_bytes().as_ref().len())
|
||||||
|
|
|
@ -11,10 +11,7 @@ impl TryFromDataBytes for Text<'_> {
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
_format: Self::Format,
|
_format: Self::Format,
|
||||||
_crop: crate::Crop,
|
_crop: crate::Crop,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error> {
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
String::from_utf8(bytes).map(Into::into)
|
String::from_utf8(bytes).map(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue