@@ -248,6 +248,7 @@ pub struct Binary<'a> {
248248
249249impl < ' a > Binary < ' a > {
250250 /// Consumes `owned` and returns an immutable `Binary`.
251+ #[ inline]
251252 pub fn from_owned ( owned : OwnedBinary , env : Env < ' a > ) -> Self {
252253 // We are transferring ownership of `owned`'s data to the
253254 // environment. Therefore, we need to prevent `owned`'s destructor being
@@ -269,6 +270,7 @@ impl<'a> Binary<'a> {
269270 ///
270271 /// If allocation fails, an error will be returned.
271272 #[ allow( clippy:: wrong_self_convention) ]
273+ #[ inline]
272274 pub fn to_owned ( & self ) -> Option < OwnedBinary > {
273275 OwnedBinary :: from_unowned ( self )
274276 }
@@ -278,6 +280,7 @@ impl<'a> Binary<'a> {
278280 /// # Errors
279281 ///
280282 /// If `term` is not a binary, an error will be returned.
283+ #[ inline]
281284 pub fn from_term ( term : Term < ' a > ) -> Result < Self , Error > {
282285 let mut binary = MaybeUninit :: uninit ( ) ;
283286 if unsafe {
@@ -315,6 +318,7 @@ impl<'a> Binary<'a> {
315318 /// # Errors
316319 ///
317320 /// If `term` is not an `iolist`, an error will be returned.
321+ #[ inline]
318322 pub fn from_iolist ( term : Term < ' a > ) -> Result < Self , Error > {
319323 let mut binary = MaybeUninit :: uninit ( ) ;
320324 if unsafe {
@@ -338,11 +342,13 @@ impl<'a> Binary<'a> {
338342
339343 /// Returns an Erlang term representation of `self`.
340344 #[ allow( clippy:: wrong_self_convention) ]
345+ #[ inline]
341346 pub fn to_term < ' b > ( & self , env : Env < ' b > ) -> Term < ' b > {
342347 self . term . in_env ( env)
343348 }
344349
345350 /// Extracts a slice containing the entire binary.
351+ #[ inline]
346352 pub fn as_slice ( & self ) -> & ' a [ u8 ] {
347353 unsafe { :: std:: slice:: from_raw_parts ( self . buf , self . size ) }
348354 }
@@ -355,6 +361,7 @@ impl<'a> Binary<'a> {
355361 /// # Errors
356362 ///
357363 /// If `offset + length` is out of bounds, an error will be returned.
364+ #[ inline]
358365 pub fn make_subbinary ( & self , offset : usize , length : usize ) -> NifResult < Binary < ' a > > {
359366 let min_len = length. checked_add ( offset) ;
360367 if min_len. ok_or ( Error :: BadArg ) ? > self . size {
@@ -452,40 +459,47 @@ pub struct NewBinary<'a> {
452459
453460impl < ' a > NewBinary < ' a > {
454461 /// Allocates a new `NewBinary`
462+ #[ inline]
455463 pub fn new ( env : Env < ' a > , size : usize ) -> Self {
456464 let ( buf, term) = unsafe { new_binary ( env, size) } ;
457465 NewBinary { buf, term, size }
458466 }
459467 /// Extracts a slice containing the entire binary.
468+ #[ inline]
460469 pub fn as_slice ( & self ) -> & [ u8 ] {
461470 unsafe { :: std:: slice:: from_raw_parts ( self . buf , self . size ) }
462471 }
463472
464473 /// Extracts a mutable slice of the entire binary.
474+ #[ inline]
465475 pub fn as_mut_slice ( & mut self ) -> & mut [ u8 ] {
466476 unsafe { :: std:: slice:: from_raw_parts_mut ( self . buf , self . size ) }
467477 }
468478}
469479
470480impl < ' a > From < NewBinary < ' a > > for Binary < ' a > {
481+ #[ inline]
471482 fn from ( new_binary : NewBinary < ' a > ) -> Self {
472483 Binary :: from_term ( new_binary. term ) . unwrap ( )
473484 }
474485}
475486
476487impl < ' a > From < NewBinary < ' a > > for Term < ' a > {
488+ #[ inline]
477489 fn from ( new_binary : NewBinary < ' a > ) -> Self {
478490 new_binary. term
479491 }
480492}
481493
482494impl Deref for NewBinary < ' _ > {
483495 type Target = [ u8 ] ;
496+ #[ inline]
484497 fn deref ( & self ) -> & [ u8 ] {
485498 self . as_slice ( )
486499 }
487500}
488501impl DerefMut for NewBinary < ' _ > {
502+ #[ inline]
489503 fn deref_mut ( & mut self ) -> & mut [ u8 ] {
490504 self . as_mut_slice ( )
491505 }
0 commit comments