Skip to content

Commit 4db27e6

Browse files
committed
impl TryFrom<i64> for SubmissionId
1 parent 2ead365 commit 4db27e6

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
@@ -117,6 +117,18 @@ impl TryFrom<u64> for SubmissionId {
117117
}
118118
}
119119

120+
impl TryFrom<i64> for SubmissionId {
121+
type Error = crate::common::errors::TryFromIntError;
122+
123+
fn try_from(value: i64) -> Result<Self, Self::Error> {
124+
if value < 0 {
125+
return Err(crate::common::errors::TryFromIntError(()));
126+
}
127+
128+
Ok(Self(u63::new(value as u64)))
129+
}
130+
}
131+
120132
impl From<&SubmissionId> for std::time::SystemTime {
121133
fn from(val: &SubmissionId) -> Self {
122134
val.system_time()

0 commit comments

Comments
 (0)