false-bottom 0.3.4

A deniable encryption scheme
Documentation
// SPDX-License-Identifier: GPL-3.0-or-later
use std::fmt;

/// Enum representing all the possible errors in this crate.
#[derive(Debug)]
pub enum FbError {
	/// Unable to decode the given data.
	DecodeError,
	
	/// The provided key is invalid w.r.t this False Bottom Object.
	InvalidKey,
	
	/// One or more of the parameters are invalid.  
	/// Valid bounds: (2 <= keybase_len <= cipher_len).
	InvalidParams,
}

impl fmt::Display for FbError {

	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
		let message = match self {
			FbError::DecodeError => "Invalid input",
			FbError::InvalidKey => "Invalid Key used",
			FbError::InvalidParams => "One or more of the parameters are invalid or out of bounds.   Valid bounds: (2 <= keybase_len <= cipher_len)",
		};

		f.write_fmt(format_args!("{message}"))
	}
}

impl std::error::Error for FbError {}