Skip to content

Commit d12e235

Browse files
committed
Fix deprecation from Rustler
1 parent 2c23e78 commit d12e235

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

native/vt_nif/src/lib.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use avt::Vt;
2-
use rustler::{Atom, Binary, Encoder, Env, Error, NifResult, ResourceArc, Term};
2+
use rustler::{Atom, Binary, Encoder, Env, Error, NifResult, Resource, ResourceArc, Term};
33
use std::str;
44
use std::{ops::RangeInclusive, sync::RwLock};
55

@@ -20,10 +20,10 @@ pub struct VtResource {
2020
vt: RwLock<Vt>,
2121
}
2222

23-
fn load(env: Env, _info: Term) -> bool {
24-
rustler::resource!(VtResource, env);
23+
impl Resource for VtResource {}
2524

26-
true
25+
fn load(env: Env, _term: Term) -> bool {
26+
env.register::<VtResource>().is_ok()
2727
}
2828

2929
#[rustler::nif]
@@ -202,8 +202,4 @@ fn convert_err<T, E>(result: Result<T, E>, error: &'static str) -> Result<T, Err
202202
}
203203
}
204204

205-
rustler::init!(
206-
"Elixir.Asciinema.Vt",
207-
[new, feed, resize, dump, dump_screen, text],
208-
load = load
209-
);
205+
rustler::init!("Elixir.Asciinema.Vt", load = load);

0 commit comments

Comments
 (0)