serde_encoded_bytes/encoding/
traits.rs

1
2
3
4
5
6
7
8
9
10
11
12
use alloc::{string::String, vec::Vec};

use serde::de;

/// A trait for encoding bytes into strings.
pub trait Encoding {
    /// Encodes the byte sequence.
    fn encode(bytes: &[u8]) -> String;

    /// Decodes the byte sequence.
    fn decode<E: de::Error>(string: &str) -> Result<Vec<u8>, E>;
}