transaction_processor/
types.rs1#[derive(Copy, Clone, Debug)]
2#[repr(u32)]
3pub enum StoreId {
4 Global = 0, Account = 1, }
7
8#[derive(Copy, Clone, Eq, PartialEq)]
9#[repr(u32)]
10pub enum InternalProcessResult {
11 Ok = 0,
12 Err = 1,
13 Ignore = 2,
14}
15
16#[derive(Clone, Debug)]
17pub enum ProcessError {
18 Generic,
19 NotFound,
20 InvalidData,
21 InvalidState,
22 Overflow,
23 Custom(String),
24 Ignore,
25}
26
27pub type ProcessResult<T> = Result<T, ProcessError>;
28
29impl From<InternalProcessResult> for Result<(), ProcessError> {
30 fn from(other: InternalProcessResult) -> Result<(), ProcessError> {
31 match other {
32 InternalProcessResult::Ok => Ok(()),
33 InternalProcessResult::Err => Err(ProcessError::Generic),
34 InternalProcessResult::Ignore => Err(ProcessError::Ignore),
35 }
36 }
37}
38
39impl From<Result<(), ProcessError>> for InternalProcessResult {
40 fn from(other: Result<(), ProcessError>) -> InternalProcessResult {
41 match other {
42 Ok(()) => InternalProcessResult::Ok,
43 Err(e) => match e {
44 ProcessError::Ignore => InternalProcessResult::Ignore,
45 _ => InternalProcessResult::Err,
46 },
47 }
48 }
49}