Skip to content

Commit

Permalink
build: migrate to stable rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Nov 15, 2024
1 parent a94a2ad commit df7e021
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 49 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]

[dependencies]
anyhow = "1"
base64 = "0.22"
base64-simd = "0.8"
cssparser = "0.29"
infer = "0.16"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-09-04"
channel = "1.82.0"
profile = "default"
17 changes: 11 additions & 6 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,12 @@ impl Image {

#[napi(setter)]
pub fn set_src(&mut self, env: Env, this: This, data: Either<Uint8Array, String>) -> Result<()> {
if let Either::A(d) = &data
&& d.len() <= 2
{
let data_is_too_small = if let Either::A(d) = &data {
d.len() <= 2
} else {
false
};
if data_is_too_small {
self.src = Some(data);
self.width = -1.0;
self.height = -1.0;
Expand Down Expand Up @@ -389,9 +392,11 @@ impl Task for BitmapDecoder {
} else {
DecodeStatus::Empty
}
} else if let Some(kind) = infer::get(&data_ref)
&& kind.matcher_type() == infer::MatcherType::Image
{
} else if if let Some(kind) = infer::get(&data_ref) {
kind.matcher_type() == infer::MatcherType::Image
} else {
false
} {
DecodeStatus::Ok(BitmapInfo {
data: Bitmap::from_buffer(data_ref.as_ptr().cast_mut(), length),
is_svg: false,
Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(link_cfg)]
#![feature(let_chains)]
#![deny(clippy::all)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::too_many_arguments)]
Expand All @@ -13,7 +11,6 @@ extern crate serde_derive;
use std::str::FromStr;
use std::{mem, slice};

use base64::Engine;
use bindgen_prelude::{BufferSlice, JavaScriptClassExt};
use napi::bindgen_prelude::{AsyncTask, ClassInstance, Either3, This, Unknown};
use napi::*;
Expand Down Expand Up @@ -399,10 +396,10 @@ impl Task for AsyncDataUrl {
let mut output = format!("data:{};base64,", &self.mime);
match &self.surface_data {
ContextOutputData::Skia(data_ref) => {
base64::engine::general_purpose::STANDARD.encode_string(data_ref.slice(), &mut output);
base64_simd::STANDARD.encode_append(data_ref.slice(), &mut output);
}
ContextOutputData::Avif(data_ref) => {
base64::engine::general_purpose::STANDARD.encode_string(data_ref.as_ref(), &mut output);
base64_simd::STANDARD.encode_append(data_ref.as_ref(), &mut output);
}
}
Ok(output)
Expand Down
72 changes: 36 additions & 36 deletions src/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,48 +224,48 @@ pub mod ffi {

#[allow(clippy::duplicated_attributes)]
// https://github.com/rust-lang/rust/issues/96192
#[link(
name = "svg",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(
not(target_os = "windows"),
link(name = "svg", kind = "static", modifiers = "+bundle,+whole-archive",)
)]
#[link(name = "svg", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skparagraph",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(target_os = "windows", link(name = "svg", kind = "static"))]
#[cfg_attr(
not(target_os = "windows"),
link(
name = "skparagraph",
kind = "static",
modifiers = "+bundle,+whole-archive"
)
)]
#[link(name = "skparagraph", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skunicode_core",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(target_os = "windows", link(name = "skparagraph", kind = "static"))]
#[cfg_attr(
not(target_os = "windows"),
link(
name = "skunicode_core",
kind = "static",
modifiers = "+bundle,+whole-archive",
)
)]
#[link(name = "skunicode_core", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skunicode_icu",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(target_os = "windows", link(name = "skunicode_core", kind = "static"))]
#[cfg_attr(
not(target_os = "windows"),
link(
name = "skunicode_icu",
kind = "static",
modifiers = "+bundle,+whole-archive"
)
)]
#[link(name = "skunicode_icu", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skia",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(target_os = "windows", link(name = "skunicode_icu", kind = "static"))]
#[cfg_attr(
not(target_os = "windows"),
link(name = "skia", kind = "static", modifiers = "+bundle,+whole-archive")
)]
#[link(name = "skia", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skiac",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
#[cfg_attr(target_os = "windows", link(name = "skia", kind = "static"))]
#[cfg_attr(
not(target_os = "windows"),
link(name = "skiac", kind = "static", modifiers = "+bundle,+whole-archive")
)]
#[link(name = "skiac", kind = "static", cfg(target_os = "windows"))]
#[cfg_attr(target_os = "windows", link(name = "skiac", kind = "static"))]
extern "C" {

pub fn skiac_clear_all_cache();
Expand Down

0 comments on commit df7e021

Please sign in to comment.