impl B64Encode<i32,String> for B64<String>{
fn encode(data:i32)->String{
let mut string:String=String::with_capacity(8);
unsafe{
let mut vector=&mut string.as_mut_vec();
vector.resize(8,0);
let pointer=vector.as_mut_ptr();
let ptr_alphabet=ALPHABET64.as_ptr();
*pointer.offset(0)=*ptr_alphabet.offset(((data>>26)&0b111111) as isize);
*pointer.offset(1)=*ptr_alphabet.offset(((data>>20)&0b111111) as isize);
*pointer.offset(2)=*ptr_alphabet.offset(((data>>14)&0b111111) as isize);
*pointer.offset(3)=*ptr_alphabet.offset(((data>>08)&0b111111) as isize);
*pointer.offset(4)=*ptr_alphabet.offset(((data>>02)&0b111111) as isize);
*pointer.offset(5)=*ptr_alphabet.offset(((data<<04)&0b111111) as isize);
*pointer.offset(6)=61;
*pointer.offset(7)=61;
}
return string;
}
}
impl<'a> B64Encode<&'a i32,String> for B64<String>{
fn encode(data:&'a i32)->String{
let mut string:String=String::with_capacity(8);
unsafe{
let mut vector=&mut string.as_mut_vec();
vector.resize(8,0);
let pointer=vector.as_mut_ptr();
let ptr_alphabet=ALPHABET64.as_ptr();
*pointer.offset(0)=*ptr_alphabet.offset(((*data>>26)&0b111111) as isize);
*pointer.offset(1)=*ptr_alphabet.offset(((*data>>20)&0b111111) as isize);
*pointer.offset(2)=*ptr_alphabet.offset(((*data>>14)&0b111111) as isize);
*pointer.offset(3)=*ptr_alphabet.offset(((*data>>08)&0b111111) as isize);
*pointer.offset(4)=*ptr_alphabet.offset(((*data>>02)&0b111111) as isize);
*pointer.offset(5)=*ptr_alphabet.offset(((*data<<04)&0b111111) as isize);
*pointer.offset(6)=61;
*pointer.offset(7)=61;
}
return string;
}
}
impl B64Decode<String,i32> for B64<i32>{
fn decode(data:String)->i32{
let mut n:u32=0;
unsafe{
let ptr_data=data.as_ptr();
let ptr_alphabet=_ALPHABET64.as_ptr();
n|=((*ptr_alphabet.offset((*ptr_data.offset(0)) as isize)) as u32)<<26;
n|=((*ptr_alphabet.offset((*ptr_data.offset(1)) as isize)) as u32)<<20;
n|=((*ptr_alphabet.offset((*ptr_data.offset(2)) as isize)) as u32)<<14;
n|=((*ptr_alphabet.offset((*ptr_data.offset(3)) as isize)) as u32)<<08;
n|=((*ptr_alphabet.offset((*ptr_data.offset(4)) as isize)) as u32)<<02;
n|=((*ptr_alphabet.offset((*ptr_data.offset(5)) as isize)) as u32)>>04;
}
return n as i32;
}
}
impl B64Decode<&'static str,i32> for B64<i32>{
fn decode(data:&'static str)->i32{
let mut n:u32=0;
unsafe{
let ptr_data=data.as_ptr();
let ptr_alphabet=_ALPHABET64.as_ptr();
n|=((*ptr_alphabet.offset((*ptr_data.offset(0)) as isize)) as u32)<<26;
n|=((*ptr_alphabet.offset((*ptr_data.offset(1)) as isize)) as u32)<<20;
n|=((*ptr_alphabet.offset((*ptr_data.offset(2)) as isize)) as u32)<<14;
n|=((*ptr_alphabet.offset((*ptr_data.offset(3)) as isize)) as u32)<<08;
n|=((*ptr_alphabet.offset((*ptr_data.offset(4)) as isize)) as u32)<<02;
n|=((*ptr_alphabet.offset((*ptr_data.offset(5)) as isize)) as u32)>>04;
}
return n as i32;
}
}