Vendor rawler 0.7.2 unmodified

The crate as crates.io publishes it, minus .cargo-ok, its Cargo.lock and
data/testdata (13 MB of sample files only its own tests read). Not yet
routed through [patch.crates-io]; the next commit is the patch.
This commit is contained in:
2026-09-27 17:33:19 -04:00
parent 0d9feb0556
commit 77a1925bac
940 changed files with 66954 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
use std::ops::Deref;
/// Buffer to hold an image in memory with enough extra space at the end for speed optimizations
pub struct PaddedBuf<'a> {
buf: PaddedBufImpl<'a>,
size: usize,
}
pub enum PaddedBufImpl<'a> {
Owned(Vec<u8>),
Ref(&'a [u8]),
}
impl<'a> PaddedBuf<'a> {
pub fn new_owned(buf: Vec<u8>, size: usize) -> Self {
Self {
buf: PaddedBufImpl::Owned(buf),
size,
}
}
pub fn new_ref(buf: &'a [u8], size: usize) -> Self {
Self {
buf: PaddedBufImpl::Ref(buf),
size,
}
}
pub fn size(&self) -> usize {
self.size
}
pub fn buf(&'a self) -> &'a [u8] {
self
}
pub fn real_size(&self) -> usize {
self.buf().len()
}
}
impl<'a> Deref for PaddedBuf<'a> {
type Target = [u8];
fn deref(&self) -> &Self::Target {
match &self.buf {
PaddedBufImpl::Owned(x) => x.as_ref(),
PaddedBufImpl::Ref(x) => x,
}
}
}