Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Sep 30, 2024
1 parent ac1fd09 commit d20dc76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src-native/tracks/cover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use image::codecs::png::PngEncoder;
use image::{ImageEncoder, ImageFormat, ImageReader};
use lazy_static::lazy_static;
use napi::bindgen_prelude::{Buffer, PromiseRaw};
use napi::{Env, JsBuffer, Task};
use napi::{Env, Task};
use redb::{Database, TableDefinition};
use std::fs;
use std::io::{BufWriter, Cursor};
Expand Down Expand Up @@ -222,7 +222,7 @@ fn to_resized_image(image_bytes: Vec<u8>, max_size: u32) -> Result<Vec<u8>> {
struct ReadCover(PathBuf, usize);
impl Task for ReadCover {
type Output = Option<Vec<u8>>;
type JsValue = Option<JsBuffer>;
type JsValue = Option<Buffer>;
fn compute(&mut self) -> napi::Result<Option<Vec<u8>>> {
let path = &self.0;
let index = self.1;
Expand All @@ -237,9 +237,9 @@ impl Task for ReadCover {

Ok(Some(image.data))
}
fn resolve(&mut self, env: Env, output: Self::Output) -> napi::Result<Option<JsBuffer>> {
fn resolve(&mut self, _env: Env, output: Self::Output) -> napi::Result<Option<Buffer>> {
match output {
Some(output) => Ok(Some(env.create_buffer_copy(output)?.into_raw())),
Some(output) => Ok(Some(Buffer::from(output))),
None => Ok(None),
}
}
Expand All @@ -253,7 +253,7 @@ pub fn read_cover_async(
track_id: String,
index: u16,
env: Env,
) -> Result<PromiseRaw<Option<JsBuffer>>> {
) -> Result<PromiseRaw<Option<Buffer>>> {
let data: &mut Data = get_data(&env)?;
let track = id_to_track(&env, &track_id)?;
let tracks_dir = &data.paths.tracks_dir;
Expand Down
7 changes: 4 additions & 3 deletions src-native/tracks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::data_js::get_data;
use crate::get_now_timestamp;
use crate::library_types::{ItemId, MsSinceUnixEpoch, Track, TrackID, TRACK_ID_MAP};
use anyhow::{bail, Context, Result};
use napi::{Env, JsArrayBuffer, JsBuffer};
use napi::bindgen_prelude::Buffer;
use napi::{Env, JsArrayBuffer};
use std::fs;
use std::path::Path;

Expand Down Expand Up @@ -174,7 +175,7 @@ pub struct JsImage {
pub index: i64,
pub total_images: i64,
pub mime_type: String,
pub data: JsBuffer,
pub data: Buffer,
}

#[napi(js_name = "get_image")]
Expand All @@ -195,7 +196,7 @@ pub fn get_image(index: u32, env: Env) -> Result<Option<JsImage>> {
index: img.index,
total_images: img.total_images,
mime_type: img.mime_type.to_string(),
data: env.create_buffer_copy(img.data)?.into_raw(),
data: Buffer::from(img.data),
};
Ok(Some(js_image))
}
Expand Down

0 comments on commit d20dc76

Please sign in to comment.