parameter.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 use std::fmt::Debug; 20 21 #[derive(Debug, Error)] 22 pub enum ParameterError { 23 #[error("expected checksum of {}, found checksum of {}", _0, _1)] 24 ChecksumMismatch(String, String), 25 26 #[error("{}: {}", _0, _1)] 27 Crate(&'static str, String), 28 29 #[error("{}", _0)] 30 Message(String), 31 32 #[error("Remote fetch is disabled, enable compiler flag for feature")] 33 RemoteFetchDisabled, 34 35 #[error("Expected size of {}, found size of {}", _0, _1)] 36 SizeMismatch(usize, usize), 37 38 #[error("{}", _0)] 39 Wasm(String), 40 41 #[error("Filesystem access is disabled, enable compiler flag for feature")] 42 FilesystemDisabled, 43 } 44 45 #[cfg(all(not(feature = "wasm"), not(target_env = "sgx")))] 46 impl From<curl::Error> for ParameterError { 47 fn from(error: curl::Error) -> Self { 48 ParameterError::Crate("curl::error", format!("{error:?}")) 49 } 50 } 51 52 impl From<std::io::Error> for ParameterError { 53 fn from(error: std::io::Error) -> Self { 54 ParameterError::Crate("std::io", format!("{error:?}")) 55 } 56 } 57 58 impl From<std::path::StripPrefixError> for ParameterError { 59 fn from(error: std::path::StripPrefixError) -> Self { 60 ParameterError::Crate("std::path", format!("{error:?}")) 61 } 62 } 63 64 impl From<ParameterError> for std::io::Error { 65 fn from(error: ParameterError) -> Self { 66 std::io::Error::other(format!("{error:?}")) 67 } 68 }