File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ impl<'a> BitBuf<'a> {
6060 }
6161 }
6262
63+ pub fn copy_aligned ( & mut self , dst : & mut [ u8 ] ) -> Result < ( ) , Insufficient > {
64+ Ok ( for i in 0 ..dst. len ( ) {
65+ dst[ i] = self . byte_at_offset ( i * 8 ) . ok_or ( Insufficient ) ?;
66+ } )
67+ }
68+
6369 pub fn copy_to_slice ( & mut self , dst : & mut [ u8 ] , bits : usize ) -> Result < ( ) , CopyError > {
6470 let bytes = bits / 8 ;
6571 let len = dst. len ( ) ;
@@ -108,4 +114,15 @@ impl<'a> BitBufMut<'a> {
108114 pub fn new ( data : & ' a mut [ u8 ] ) -> Self {
109115 BitBufMut { data, prefix : 0 }
110116 }
117+
118+ pub fn skip ( & ' a mut self , bits : usize ) -> Result < ( ) , Insufficient > {
119+ self . prefix += ( bits & 7 ) as u8 ;
120+ if self . prefix >= 8 {
121+ self . prefix -= 8 ;
122+ self . data = self . data . get_mut ( ( bits / 8 ) + 1 ..) . ok_or ( Insufficient ) ?;
123+ } else {
124+ self . data = self . data . get_mut ( bits / 8 ..) . ok_or ( Insufficient ) ?;
125+ }
126+ Ok ( ( ) )
127+ }
111128}
You can’t perform that action at this time.
0 commit comments