Struct Encode

Source
pub struct Encode {}

Implementations§

Source§

impl Encode

Source

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 in charset 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.