runtime/
lib.rs

1// Copyright 2020-2021 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4// No std maybe for later
5// #![no_std]
6
7mod boxed;
8pub mod locked_memory;
9pub mod memories;
10mod types;
11pub mod utils;
12
13pub use thiserror::Error as DeriveError;
14pub use types::Bytes;
15
16/// The memory types of this crate shall return this message when trying to debug them
17pub const DEBUG_MSG: &str = "Content of Locked Memory is hidden";
18
19/// The different types of Error that may be encountered while using this crate
20#[derive(Debug, DeriveError)]
21pub enum MemoryError {
22    #[error("encryption error")]
23    EncryptionError,
24
25    #[error("decryption error")]
26    DecryptionError,
27
28    #[error("illegal non-contiguous size")]
29    NCSizeNotAllowed,
30
31    #[error("error while refreshing non-contiguous memory")]
32    NCRefreshError,
33
34    #[error("lock unavailable")]
35    LockNotAvailable,
36
37    #[error("file system error")]
38    FileSystemError,
39
40    #[error("illegal zero-sized value provided")]
41    ZeroSizedNotAllowed,
42
43    #[error("failed to allocate memory ({0})")]
44    Allocation(String),
45
46    #[error("intended operation failed: ({0})")]
47    Operation(String),
48
49    #[error("illegal tentative of using zeroized memory")]
50    IllegalZeroizedUsage,
51}
52
53/// A simple trait to force the types to call `zeroize()` when dropping
54pub trait ZeroizeOnDrop {}