chore: fix *.rs formatting
This commit is contained in:
Generated
-133
@@ -83,31 +83,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.35"
|
||||
@@ -145,19 +120,6 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"bstr",
|
||||
"log",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "grep-matcher"
|
||||
version = "0.1.8"
|
||||
@@ -195,22 +157,6 @@ dependencies = [
|
||||
"memmap2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"globset",
|
||||
"log",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"same-file",
|
||||
"walkdir",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.9"
|
||||
@@ -226,12 +172,6 @@ dependencies = [
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.85"
|
||||
@@ -381,15 +321,6 @@ version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
@@ -431,19 +362,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.8"
|
||||
@@ -467,27 +385,6 @@ version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi-grep"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"grep-matcher",
|
||||
"grep-regex",
|
||||
"grep-searcher",
|
||||
"ignore",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.108"
|
||||
@@ -533,36 +430,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02aae0f83f69aafc94776e879363e9771d7ecbffe2c7fbb6c14c5e00dfe88439"
|
||||
|
||||
[[package]]
|
||||
name = "zune-core"
|
||||
version = "0.5.1"
|
||||
|
||||
@@ -15,21 +15,21 @@ use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum SamplingFilter {
|
||||
Nearest = 1,
|
||||
Triangle = 2,
|
||||
Nearest = 1,
|
||||
Triangle = 2,
|
||||
CatmullRom = 3,
|
||||
Gaussian = 4,
|
||||
Lanczos3 = 5,
|
||||
Gaussian = 4,
|
||||
Lanczos3 = 5,
|
||||
}
|
||||
|
||||
impl From<SamplingFilter> for FilterType {
|
||||
fn from(filter: SamplingFilter) -> Self {
|
||||
match filter {
|
||||
SamplingFilter::Nearest => FilterType::Nearest,
|
||||
SamplingFilter::Triangle => FilterType::Triangle,
|
||||
SamplingFilter::CatmullRom => FilterType::CatmullRom,
|
||||
SamplingFilter::Gaussian => FilterType::Gaussian,
|
||||
SamplingFilter::Lanczos3 => FilterType::Lanczos3,
|
||||
SamplingFilter::Nearest => Self::Nearest,
|
||||
SamplingFilter::Triangle => Self::Triangle,
|
||||
SamplingFilter::CatmullRom => Self::CatmullRom,
|
||||
SamplingFilter::Gaussian => Self::Gaussian,
|
||||
SamplingFilter::Lanczos3 => Self::Lanczos3,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ pub struct PhotonImage {
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl PhotonImage {
|
||||
/// Create a new PhotonImage from encoded image bytes (PNG, JPEG, WebP, GIF).
|
||||
/// Create a new `PhotonImage` from encoded image bytes (PNG, JPEG, WebP, GIF).
|
||||
#[wasm_bindgen(js_name = new_from_byteslice)]
|
||||
pub fn new_from_byteslice(bytes: &[u8]) -> Result<PhotonImage, JsValue> {
|
||||
pub fn new_from_byteslice(bytes: &[u8]) -> Result<Self, JsValue> {
|
||||
let reader = ImageReader::new(Cursor::new(bytes))
|
||||
.with_guessed_format()
|
||||
.map_err(|e| JsValue::from_str(&format!("Failed to detect image format: {e}")))?;
|
||||
@@ -53,7 +53,7 @@ impl PhotonImage {
|
||||
.decode()
|
||||
.map_err(|e| JsValue::from_str(&format!("Failed to decode image: {e}")))?;
|
||||
|
||||
Ok(PhotonImage { img })
|
||||
Ok(Self { img })
|
||||
}
|
||||
|
||||
/// Get the width of the image.
|
||||
@@ -72,7 +72,8 @@ impl PhotonImage {
|
||||
#[wasm_bindgen(js_name = get_bytes)]
|
||||
pub fn get_bytes(&self) -> Result<Vec<u8>, JsValue> {
|
||||
let mut buffer = Vec::new();
|
||||
self.img
|
||||
self
|
||||
.img
|
||||
.write_to(&mut Cursor::new(&mut buffer), ImageFormat::Png)
|
||||
.map_err(|e| JsValue::from_str(&format!("Failed to encode PNG: {e}")))?;
|
||||
Ok(buffer)
|
||||
@@ -83,7 +84,8 @@ impl PhotonImage {
|
||||
pub fn get_bytes_jpeg(&self, quality: u8) -> Result<Vec<u8>, JsValue> {
|
||||
let mut buffer = Vec::new();
|
||||
let encoder = image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buffer, quality);
|
||||
self.img
|
||||
self
|
||||
.img
|
||||
.write_with_encoder(encoder)
|
||||
.map_err(|e| JsValue::from_str(&format!("Failed to encode JPEG: {e}")))?;
|
||||
Ok(buffer)
|
||||
@@ -92,12 +94,7 @@ impl PhotonImage {
|
||||
|
||||
/// Resize an image to the specified dimensions.
|
||||
#[wasm_bindgen]
|
||||
pub fn resize(
|
||||
image: &PhotonImage,
|
||||
width: u32,
|
||||
height: u32,
|
||||
filter: SamplingFilter,
|
||||
) -> PhotonImage {
|
||||
pub fn resize(image: &PhotonImage, width: u32, height: u32, filter: SamplingFilter) -> PhotonImage {
|
||||
let resized = image.img.resize_exact(width, height, filter.into());
|
||||
PhotonImage { img: resized }
|
||||
}
|
||||
|
||||
@@ -164,7 +164,8 @@ impl Sink for MatchCollector {
|
||||
fn matched(&mut self, _searcher: &Searcher, mat: &SinkMatch<'_>) -> Result<bool, Self::Error> {
|
||||
self.match_count += 1;
|
||||
|
||||
// If we already hit the limit, stop now (after-context for previous match was collected)
|
||||
// If we already hit the limit, stop now (after-context for previous match was
|
||||
// collected)
|
||||
if self.limit_reached {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user