From 323538bcff6caa3c6d7b87a2df40620dfcc5476d Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Tue, 26 Dec 2023 12:23:28 -0500 Subject: [PATCH] Handle timeout int conversion better --- ctru-rs/src/services/srv.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ctru-rs/src/services/srv.rs b/ctru-rs/src/services/srv.rs index eeaa723..98b7282 100644 --- a/ctru-rs/src/services/srv.rs +++ b/ctru-rs/src/services/srv.rs @@ -16,11 +16,14 @@ pub trait HandleExt { impl HandleExt for Handle { fn wait_for_event(self, timeout: Duration) -> crate::Result<()> { + let timeout = i64::try_from(timeout.as_nanos()).map_err(|e| { + crate::Error::Other(format!( + "Failed to convert timeout to 64-bit nanoseconds: {}", + e + )) + })?; unsafe { - ResultCode(ctru_sys::svcWaitSynchronization( - self, - timeout.as_nanos() as i64, - ))?; + ResultCode(ctru_sys::svcWaitSynchronization(self, timeout))?; } Ok(()) }