@@ -242,6 +242,7 @@ pub struct Binary<'a> {
242242
243243impl < ' a > Binary < ' a > {
244244 /// Consumes `owned` and returns an immutable `Binary`.
245+ #[ inline]
245246 pub fn from_owned ( owned : OwnedBinary , env : Env < ' a > ) -> Self {
246247 // We are transferring ownership of `owned`'s data to the
247248 // environment. Therefore, we need to prevent `owned`'s destructor being
@@ -267,6 +268,7 @@ impl<'a> Binary<'a> {
267268 ///
268269 /// If allocation fails, an error will be returned.
269270 #[ allow( clippy:: wrong_self_convention) ]
271+ #[ inline]
270272 pub fn to_owned ( & self ) -> Option < OwnedBinary > {
271273 OwnedBinary :: from_unowned ( self )
272274 }
@@ -276,6 +278,7 @@ impl<'a> Binary<'a> {
276278 /// # Errors
277279 ///
278280 /// If `term` is not a binary, an error will be returned.
281+ #[ inline]
279282 pub fn from_term ( term : Term < ' a > ) -> Result < Self , Error > {
280283 let mut binary = MaybeUninit :: uninit ( ) ;
281284 if unsafe {
@@ -299,6 +302,7 @@ impl<'a> Binary<'a> {
299302 /// # Errors
300303 ///
301304 /// If `term` is not an `iolist`, an error will be returned.
305+ #[ inline]
302306 pub fn from_iolist ( term : Term < ' a > ) -> Result < Self , Error > {
303307 let mut binary = MaybeUninit :: uninit ( ) ;
304308 if unsafe {
@@ -319,11 +323,13 @@ impl<'a> Binary<'a> {
319323
320324 /// Returns an Erlang term representation of `self`.
321325 #[ allow( clippy:: wrong_self_convention) ]
326+ #[ inline]
322327 pub fn to_term < ' b > ( & self , env : Env < ' b > ) -> Term < ' b > {
323328 self . term . in_env ( env)
324329 }
325330
326331 /// Extracts a slice containing the entire binary.
332+ #[ inline]
327333 pub fn as_slice ( & self ) -> & ' a [ u8 ] {
328334 unsafe { :: std:: slice:: from_raw_parts ( self . inner . data , self . inner . size ) }
329335 }
@@ -336,6 +342,7 @@ impl<'a> Binary<'a> {
336342 /// # Errors
337343 ///
338344 /// If `offset + length` is out of bounds, an error will be returned.
345+ #[ inline]
339346 pub fn make_subbinary ( & self , offset : usize , length : usize ) -> NifResult < Binary < ' a > > {
340347 let min_len = length. checked_add ( offset) ;
341348 if min_len. ok_or ( Error :: BadArg ) ? > self . inner . size {
@@ -415,40 +422,47 @@ pub struct NewBinary<'a> {
415422
416423impl < ' a > NewBinary < ' a > {
417424 /// Allocates a new `NewBinary`
425+ #[ inline]
418426 pub fn new ( env : Env < ' a > , size : usize ) -> Self {
419427 let ( buf, term) = unsafe { new_binary ( env, size) } ;
420428 NewBinary { buf, term, size }
421429 }
422430 /// Extracts a slice containing the entire binary.
431+ #[ inline]
423432 pub fn as_slice ( & self ) -> & [ u8 ] {
424433 unsafe { :: std:: slice:: from_raw_parts ( self . buf , self . size ) }
425434 }
426435
427436 /// Extracts a mutable slice of the entire binary.
437+ #[ inline]
428438 pub fn as_mut_slice ( & mut self ) -> & mut [ u8 ] {
429439 unsafe { :: std:: slice:: from_raw_parts_mut ( self . buf , self . size ) }
430440 }
431441}
432442
433443impl < ' a > From < NewBinary < ' a > > for Binary < ' a > {
444+ #[ inline]
434445 fn from ( new_binary : NewBinary < ' a > ) -> Self {
435446 Binary :: from_term ( new_binary. term ) . unwrap ( )
436447 }
437448}
438449
439450impl < ' a > From < NewBinary < ' a > > for Term < ' a > {
451+ #[ inline]
440452 fn from ( new_binary : NewBinary < ' a > ) -> Self {
441453 new_binary. term
442454 }
443455}
444456
445457impl < ' a > Deref for NewBinary < ' a > {
446458 type Target = [ u8 ] ;
459+ #[ inline]
447460 fn deref ( & self ) -> & [ u8 ] {
448461 self . as_slice ( )
449462 }
450463}
451464impl < ' a > DerefMut for NewBinary < ' a > {
465+ #[ inline]
452466 fn deref_mut ( & mut self ) -> & mut [ u8 ] {
453467 self . as_mut_slice ( )
454468 }
0 commit comments