38 releases

Uses old Rust 2015

0.4.7 Jun 4, 2017
0.4.6 Jun 4, 2017
0.3.19 Jun 3, 2017
0.3.8 May 30, 2017
0.1.0 May 28, 2017

#2431 in Encoding

Download history 46/week @ 2024-07-28 54/week @ 2024-09-22 3/week @ 2024-09-29

94 downloads per month

MIT license

44KB
822 lines

rust-base64

Build Status Build status Docs.rs Crates.io License

Install

Cargo.toml

[dependencies]
wdg-base64="*"

How to use?

    B64::<type>::encode(data);
    B64::<type>::decode(data);

Examples

extern crate wdg_base64;
use wdg_base64::{B64,B64Encode,B64Decode};

fn main(){

    // u8
    println!("{}",B64::<String>::encode(5u8));
    println!("{}",B64::<u8>::decode(String::from("BQ==")));
    
    // u16
    println!("{}",B64::<String>::encode(5u16));
    println!("{}",B64::<u16>::decode(String::from("AAU=")));
    
}

How to use function pointers?

extern crate wdg_base64;
use wdg_base64::{B64,B64Encode,B64Decode};

fn main(){

    let u8b64:fn(u8)->String=B64::<String>::encode;
    let b64u8:fn(String)->u8=B64::<u8>::decode;

    assert_eq!(B64::<String>::encode(10u8),u8b64(10u8));
    assert_eq!(B64::<u8>::decode(String::from("Cg==")),b64u8(String::from("Cg==")));
    assert_eq!(b64u8(u8b64(10u8)),10u8);
    
}

No runtime deps