Struct SmolBlob

Source
pub struct SmolBlob { /* private fields */ }

Implementations§

Source§

impl SmolBlob

SmolBlob is a chunk of smol data

Source

pub fn buffer(&self) -> Vec<u8>

converts the SmolBlob data into a valid file buffer

Source

pub fn len(&self) -> usize

returns the inner buffer length ONLY, not to be confused by SmolBlob::buffer.len()

Source

pub fn encode(str: &String) -> SmolBlob

encodes a String and returns a SmolBlob

§example
let encoded: SmolBlob = SmolBlob::encode(&input);
fs::write("smol.bin", &encoded.buffer()).unwrap();
Source

pub fn decode(input: &Vec<u8>) -> Result<String, Error>

decodes a SmolBlob::buffer and returns a String

§example
let decoded: String = SmolBlob::decode(&encoded.buffer()).unwrap();
fs::write("unsmol.bin", &decoded).unwrap();
Source

pub fn decode_blob(input: &SmolBlob) -> Result<String, Error>

decodes a SmolBlob and returns a String
internally this is the same as SmolBlob::decode but with SmolBlob instead of Vec<u8> buffer

§example
let decoded: String = SmolBlob::decode_blob(&encoded).unwrap();
fs::write("unsmol.bin", &decoded).unwrap();

Trait Implementations§

Source§

impl Default for SmolBlob

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.