#[cfg(any(feature = "cloud-engine-marketplace", feature = "caffeine"))]
mod nat;
mod wire;
#[cfg(any(feature = "cloud-engine-marketplace", feature = "caffeine"))]
pub use nat::Nat;
pub(crate) use wire::{Decode, Reader, Schema};
#[cfg(feature = "management-snapshots")]
pub(crate) use wire::{KnownElements, KnownOptional};
#[derive(Clone, Copy, Debug)]
pub struct Limits {
pub bytes: usize,
pub header: usize,
pub types: usize,
pub work: usize,
pub allocation: usize,
pub vector: usize,
pub skipping: usize,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
Malformed,
Unsupported,
Type,
Arity,
Trailing,
Limit,
Allocation,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Malformed => "malformed Candid message",
Self::Unsupported => "unsupported Candid representation",
Self::Type => "incompatible Candid projection",
Self::Arity => "unexpected Candid argument count",
Self::Trailing => "trailing Candid bytes",
Self::Limit => "Candid decoding limit exceeded",
Self::Allocation => "Candid allocation failed",
})
}
}
impl std::error::Error for Error {}
pub(crate) fn decode<T: Decode>(input: &[u8], limits: Limits) -> Result<T, Error> {
wire::decode(input, limits)
}
#[cfg(any(feature = "management-snapshots", feature = "caffeine"))]
pub(crate) mod encode;
#[cfg(any(feature = "management-snapshots", feature = "caffeine"))]
pub(crate) use wire::decode_empty;
pub(crate) mod projection;