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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! [](./LICENSE)
//! [](https://crates.io/crates/cdumay_base64)
//! [](https://docs.rs/cdumay_base64)
//! [](https://github.com/cdumay/cdumay_base64)
//!
//! A small crate to manipulate base64 data.
//!
//! ## Features
//!
//! - Maps all variants of `base64::DecodeError` into structured `cdumay_core::Error` types.
//! - Provides unique error codes, HTTP status codes, and human-readable messages.
//! - Easily attach contextual metadata for better debugging.
//! - Simple integration into any Rust project using `base64` and `cdumay_core`.
//! - Provides convenient macro for error conversion
//!
//! ## Usage
//!
//! Using the `Base64DecodeErrorConverter` directly:
//! ```rust
//! use cdumay_base64::base64::{engine::general_purpose, Engine as _};
//! use std::collections::BTreeMap;
//! use cdumay_core::{ErrorConverter, Error};
//! use cdumay_base64::Base64DecodeErrorConverter;
//!
//! fn decode_base64(input: &str) -> cdumay_core::Result<Vec<u8>> {
//! general_purpose::STANDARD.decode(input).map_err(|e| {
//! let mut context = BTreeMap::new();
//! context.insert("input".to_string(), serde_value::Value::String(input.to_string()));
//! Base64DecodeErrorConverter::convert(&e, "Failed to decode base64".to_string(), context)
//! })
//! }
//! ```
//! Using the `convert_decode_result!` macro:
//! ```rust
//! use cdumay_base64::base64::{engine::general_purpose, Engine as _};
//! use cdumay_core::{ErrorConverter, Error};
//! use std::collections::BTreeMap;
//! use cdumay_base64::convert_decode_result;
//!
//! fn decode_base64(input: &str) -> cdumay_core::Result<Vec<u8>> {
//! let mut context = BTreeMap::new();
//! context.insert("input".to_string(), serde_value::Value::String(input.to_string()));
//! convert_decode_result!(general_purpose::STANDARD.decode(input), context, "Failed to decode base64")
//! }
//! ```
//!
pub use *;
/// Re-export of the `base64` crate for use in dependent libraries.
pub use base64;