use jni::{
objects::{JByteArray, JObject},
JNIEnv,
};
pub fn decode_byte_array(env: &mut JNIEnv, payload: &JByteArray) -> Result<Vec<u8>, String> {
env.convert_byte_array(payload)
.map_err(|err| format!("Error while decoding JByteArray: {}", err))
}
pub fn encode_byte_array<'local>(
env: &mut JNIEnv<'local>,
bytes: &[u8],
) -> Result<JByteArray<'local>, String> {
env.byte_array_from_slice(bytes)
.map_err(|err| format!("Error while encoding JByteArray: {}", err))
}
pub fn null_byte_array() -> JByteArray<'static> {
JByteArray::from(JObject::null())
}