From 4db27e60d8527b8c13bd8eb1e2f43bdeb8230da1 Mon Sep 17 00:00:00 2001 From: Daan Rijks Date: Thu, 20 Nov 2025 10:57:34 +0100 Subject: [PATCH] impl TryFrom for SubmissionId --- opsqueue/src/common/submission.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/opsqueue/src/common/submission.rs b/opsqueue/src/common/submission.rs index cdfc95e..0331180 100644 --- a/opsqueue/src/common/submission.rs +++ b/opsqueue/src/common/submission.rs @@ -117,6 +117,18 @@ impl TryFrom for SubmissionId { } } +impl TryFrom for SubmissionId { + type Error = crate::common::errors::TryFromIntError; + + fn try_from(value: i64) -> Result { + if value < 0 { + return Err(crate::common::errors::TryFromIntError(())); + } + + Ok(Self(u63::new(value as u64))) + } +} + impl From<&SubmissionId> for std::time::SystemTime { fn from(val: &SubmissionId) -> Self { val.system_time()