Skip to content

Commit 1c43369

Browse files
committed
Add decoding of Binary to RustlerDecoder
This allows us to decode directly into a Binary saving us if we wish to convert it to some other type than always going through Vec<u8> which will encur another copy
1 parent c1d29a0 commit 1c43369

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arm/src/rustler_util.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ pub trait RustlerEncoder {
9797
pub trait RustlerDecoder<'a>: Sized + 'a {
9898
fn rustler_decode(term: Term<'a>) -> NifResult<Self>;
9999
}
100+
impl<'a> RustlerDecoder<'a> for Binary<'a> {
101+
fn rustler_decode(term: Term<'a>) -> NifResult<Self> {
102+
term.decode::<Binary<'a>>()
103+
}
104+
}
100105

101106
impl RustlerEncoder for Vec<u8> {
102107
fn rustler_encode<'a>(&self, env: Env<'a>) -> Result<Term<'a>, Error> {

0 commit comments

Comments
 (0)