File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 6767 dereferences to ` [u8] `
6868- documented creating ` Bytes ` from ` Arc ` sources without an extra wrapper and
6969 removed the corresponding task from the inventory
70+ - implemented ` bytes::Buf ` for ` Bytes ` and ` From<Bytes> ` for ` bytes::Bytes ` for
71+ seamless integration with Tokio and other libraries
7072
7173## 0.19.3 - 2025-05-30
7274- implemented ` Error ` for ` ViewError `
Original file line number Diff line number Diff line change 11[package ]
22name = " anybytes"
3- version = " 0.19.3 "
3+ version = " 0.19.4 "
44edition = " 2021"
55license = " MIT"
66repository = " https://github.com/triblespace/anybytes"
Original file line number Diff line number Diff line change @@ -433,6 +433,13 @@ impl<T: ByteSource + ByteOwner> From<Arc<T>> for Bytes {
433433 }
434434}
435435
436+ #[ cfg( feature = "bytes" ) ]
437+ impl From < Bytes > for bytes:: Bytes {
438+ fn from ( bytes : Bytes ) -> Self {
439+ bytes:: Bytes :: from_owner ( bytes)
440+ }
441+ }
442+
436443impl Deref for Bytes {
437444 type Target = [ u8 ] ;
438445 #[ inline]
@@ -501,6 +508,27 @@ impl fmt::Debug for Bytes {
501508 }
502509}
503510
511+ #[ cfg( feature = "bytes" ) ]
512+ impl bytes:: Buf for Bytes {
513+ #[ inline]
514+ fn remaining ( & self ) -> usize {
515+ self . data . len ( )
516+ }
517+
518+ #[ inline]
519+ fn chunk ( & self ) -> & [ u8 ] {
520+ self . data
521+ }
522+
523+ #[ inline]
524+ fn advance ( & mut self , cnt : usize ) {
525+ if cnt > self . data . len ( ) {
526+ panic ! ( "advance out of bounds: {} > {}" , cnt, self . data. len( ) ) ;
527+ }
528+ self . data = & self . data [ cnt..] ;
529+ }
530+ }
531+
504532#[ cfg( test) ]
505533mod tests {
506534 use super :: Bytes ;
You can’t perform that action at this time.
0 commit comments