1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.

//! The standard success codes used by TicKV.

/// Standard success codes.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SuccessCode {
    /// Operation complete, no changes have been made to flash.
    Complete,
    /// All changes have been written to flash. The operation is complete.
    Written,
    /// The write operation has been queued
    Queued,
}

impl From<SuccessCode> for isize {
    fn from(original: SuccessCode) -> isize {
        match original {
            SuccessCode::Complete => -1,
            SuccessCode::Written => -2,
            SuccessCode::Queued => -3,
        }
    }
}

impl From<SuccessCode> for usize {
    fn from(original: SuccessCode) -> usize {
        isize::from(original) as usize
    }
}