From c8a8b3dacfd0bab9b689e86fbf345f42a5789dab Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 24 Sep 2023 13:12:45 +0200 Subject: [PATCH] Fix rebase --- rustler/src/resource.rs | 4 ++-- rustler_tests/native/rustler_test/src/test_resource.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rustler/src/resource.rs b/rustler/src/resource.rs index fbbf33c4..e0a467b8 100644 --- a/rustler/src/resource.rs +++ b/rustler/src/resource.rs @@ -11,11 +11,11 @@ use std::{marker::PhantomData, mem::MaybeUninit}; use rustler_sys::{ErlNifMonitor, ErlNifPid, ErlNifResourceDown}; -use super::{Binary, Decoder, Encoder, Env, Error, NifResult, Term}; +use super::{Binary, Decoder, Encoder, Env, Error, LocalPid, Term}; use crate::wrapper::{ c_void, resource, NifResourceFlags, MUTABLE_NIF_RESOURCE_HANDLE, NIF_ENV, NIF_RESOURCE_TYPE, - LocalPid, }; +use crate::NifResult; /// Re-export a type used by the `resource!` macro. #[doc(hidden)] diff --git a/rustler_tests/native/rustler_test/src/test_resource.rs b/rustler_tests/native/rustler_test/src/test_resource.rs index 6bfca274..08283b61 100644 --- a/rustler_tests/native/rustler_test/src/test_resource.rs +++ b/rustler_tests/native/rustler_test/src/test_resource.rs @@ -1,5 +1,5 @@ use rustler::{Binary, Env, LocalPid, Monitor, MonitorResource, ResourceArc, ResourceArcMonitor}; -use std::sync::{RwLock, Mutex}; +use std::sync::{Mutex, RwLock}; pub struct TestResource { test_field: RwLock, @@ -103,6 +103,7 @@ pub fn resource_make_with_binaries() -> ResourceArc { }) } +#[rustler::nif] pub fn monitor_resource_make() -> ResourceArc { ResourceArc::new(TestMonitorResource { inner: Mutex::new(TestMonitorResourceInner { @@ -137,7 +138,11 @@ pub fn resource_make_binary_from_vec(env: Env, resource: ResourceArc, pid: LocalPid) { +pub fn monitor_resource_monitor( + env: Env, + resource: ResourceArc, + pid: LocalPid, +) { let mut inner = resource.inner.lock().unwrap(); inner.mon = resource.monitor(Some(&env), &pid); assert!(inner.mon.is_some());