1use std::fmt;
4
5use crate::{CoreError, types::MAX_INPUT_BYTES};
6
7#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
9pub struct InputId(pub(crate) u64);
10
11impl fmt::Debug for InputId {
12 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
13 formatter.write_str("InputId(<opaque>)")
14 }
15}
16
17impl InputId {
18 pub const fn get(self) -> u64 {
19 self.0
20 }
21}
22
23#[derive(Clone, Debug, Eq, PartialEq)]
25pub struct InputRequest {
26 id: InputId,
27 bytes: Vec<u8>,
28}
29
30impl InputRequest {
31 pub(crate) fn new(id: InputId, bytes: Vec<u8>) -> Result<Self, CoreError> {
32 if bytes.is_empty() || bytes.len() > MAX_INPUT_BYTES {
33 return Err(CoreError::InputTooLarge { size: bytes.len() });
34 }
35 Ok(Self { id, bytes })
36 }
37
38 pub const fn id(&self) -> InputId {
39 self.id
40 }
41
42 pub fn bytes(&self) -> &[u8] {
43 &self.bytes
44 }
45}
46
47#[derive(Clone, Copy, Debug, Eq, PartialEq)]
49pub enum InputOutcome {
50 Accepted,
51 Rejected,
52 Uncertain,
53 Superseded,
54}
55
56#[derive(Clone, Copy, Debug, Eq, PartialEq)]
58pub struct InputResult {
59 pub id: InputId,
60 pub outcome: InputOutcome,
61}