Skip to content

Commit 6d14d43

Browse files
committed
impl TryFrom<i64> for SubmissionId
1 parent c943a54 commit 6d14d43

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

opsqueue/src/common/submission.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ impl TryFrom<u64> for SubmissionId {
9999
}
100100
}
101101

102+
impl TryFrom<i64> for SubmissionId {
103+
type Error = crate::common::errors::TryFromIntError;
104+
105+
fn try_from(value: i64) -> Result<Self, Self::Error> {
106+
if value < 0 {
107+
return Err(crate::common::errors::TryFromIntError(()));
108+
}
109+
110+
Ok(Self(u63::new(value as u64)))
111+
}
112+
}
113+
102114
impl From<&SubmissionId> for std::time::SystemTime {
103115
fn from(val: &SubmissionId) -> Self {
104116
val.system_time()

0 commit comments

Comments
 (0)