nskinkel / libredsalt

2 stars 1 forks source link

should we standardize byte return types? #12

Open nskinkel opened 9 years ago

nskinkel commented 9 years ago

All functions return a Result<T, Err>, but I wonder if we should standardize the type of bytes we're returning? Some functions return a [u8], and some return a Vec<u8>. I'm wondering if we should just make all functions that return bytes return a Vec<u8>, even if we technically do know the byte length that will be returned at compile-time.

For reference, the C++ NaCL API always returns std::string as far as I know, so it might make sense to do something similar with Vec<u8>.

dwtj commented 9 years ago

I'd actually prefer using both. Returning a [u8; SIZE] gives more type information than Vec<u8>. You're right that it is somewhat incongruous with the C++-API's style, but C++ doesn't have a common array-like type like [u8; SIZE]. This API isn't the primary one that we're intending to reveal to users anyway.