pub struct Encode {}
Implementations§
Source§impl Encode
impl Encode
Sourcepub fn execute(charset: &str, encode_str: &str) -> Result<String, EncodeError>
pub fn execute(charset: &str, encode_str: &str) -> Result<String, EncodeError>
Encodes a given input string into an encoded format using a specified character set (charset
).
This function groups bytes in chunks of 3 and maps them into 4-character segments based on charset
.
§Parameters
charset
: A string representing the character set to use for encoding. Each character incharset
should have a unique position to ensure accurate encoding.encode_str
: The input string to encode. It will be converted to bytes and processed in 3-byte chunks.
§Returns
Returns a Result
containing the encoded String
if successful, or a EncodeError
if the charset is invalid.
§Example
use bin_encode_decode::*;
let charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=";
let original_str = "test";
let encoded_str = Encode::execute(charset, original_str);
assert_eq!(encoded_str.unwrap(), "aab0aabLaabZaab0");
Auto Trait Implementations§
impl Freeze for Encode
impl RefUnwindSafe for Encode
impl Send for Encode
impl Sync for Encode
impl Unpin for Encode
impl UnwindSafe for Encode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more