wdg-base32 0.3.2

The Base32 Data Encoding
Documentation
impl B32Encode<u8,String> for B32<String>{
    fn encode(data:u8)->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=ALPHABET32.as_ptr();
            *pointer.offset(0)=*ptr_alphabet.offset(((data>>3)&0b11111) as isize);
            *pointer.offset(1)=*ptr_alphabet.offset(((data<<2)&0b11111) as isize);
            *pointer.offset(2)=61;
            *pointer.offset(3)=61;
            *pointer.offset(4)=61;
            *pointer.offset(5)=61;
            *pointer.offset(6)=61;
            *pointer.offset(7)=61;
        }
        return string;
    }
}

impl B32Decode<String,u8> for B32<u8>{
    fn validation(data:String)->B32Error{
        return b32_validation(data.as_ptr(),data.len(),_ALPHABET32.as_ptr(),6,0b1000000,8);
    }
    fn decode(data:String)->u8{
        let mut n=0u8;
        unsafe{
            let ptr_data=data.as_ptr();
            let ptr_alphabet=_ALPHABET32.as_ptr();
            n|=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3;
            n|=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
        }
        return n;
    }
}

// fn validation(ptr:*const u8,mut len:usize,pad:u16,rem:usize)->B32Error{
//     if len%rem!=0 {return B32Error::InvalidLength(len,0,rem);}
//
//     let ind=len-1;
//     unsafe{while ind>=0 && *ptr.offset(ind)==61{ind-=1;}}
//     let pdl=len-1-ind;
//     if (pad>>pdl)&0b1==0 {return B32Error::InvalidPadding(pdl,pad);}
//
//
//     let ptr_alphabet=_ALPHABET32.as_ptr();
//     for i in 0..(ind+1){
//         if *ptr_alphabet.offset(*ptr.offset(i) as isize)==255{
//             return B32Error::InvalidChar(i as usize,*ptr.offset(i));
//         }
//     }
//
//     return B32Error::Null;
// }