Skip to content

Commit 37c0d93

Browse files
committed
handle
1 parent f4ef34b commit 37c0d93

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/libs/services/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,15 @@ impl<'a> Service<'a> {
209209
drop(writer);
210210

211211
unsafe {
212-
SetServiceStatus(*self.handle.read().unwrap(), &status);
212+
SetServiceStatus(self.handle(), &status);
213213
}
214214
}
215215

216+
/// The raw handle representing the service.
217+
pub fn handle(&self) -> *mut core::ffi::c_void {
218+
*self.handle.read().unwrap()
219+
}
220+
216221
/// The current state the service.
217222
pub fn state(&self) -> State {
218223
let reader = self.status.read().unwrap();

crates/tests/libs/services/tests/service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ fn start_stop() {
77

88
Service::new()
99
.can_fallback(|_| {})
10-
.run(|_, command| {
10+
.run(|service, command| {
11+
assert!(service.handle().is_null());
1112
log.push(command);
1213
})
1314
.unwrap();

0 commit comments

Comments
 (0)