File tree Expand file tree Collapse file tree 12 files changed +111
-38
lines changed Expand file tree Collapse file tree 12 files changed +111
-38
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ members = [
10
10
" src/memory/bitstreamcache" ,
11
11
" src/memory/bitstreamer" ,
12
12
" src/memory/variable_length_load" ,
13
+ " src/memory/fixed_length_load" ,
13
14
" src/memory/bytevacuumer" ,
14
15
" src/memory/bytestreamer" ,
15
16
" src/misc/md5" ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ rawspeed-memory-bitstreamcache = { path = "../../../memory/bitstreamcache" }
19
19
rawspeed-memory-bitstreamer = { path = " ../../../memory/bitstreamer" }
20
20
rawspeed-memory-endianness = { path = " ../../../memory/endianness" }
21
21
rawspeed-memory-variable_length_load = { path = " ../../../memory/variable_length_load" }
22
+ rawspeed-memory-fixed_length_load = { path = " ../../../memory/fixed_length_load" }
22
23
rawspeed-std = { path = " ../../../std" }
23
24
rawspeed-std-ndslice = { path = " ../../../std/ndslice" }
24
25
Original file line number Diff line number Diff line change 1
- use rawspeed_common:: bit_transmutation:: CopyFromSlice ;
2
1
use rawspeed_common:: bit_transmutation:: FromNeBytes ;
3
- use rawspeed_common:: bit_transmutation:: LoadFromSlice ;
4
2
use rawspeed_common:: common:: Bitwidth ;
5
3
use rawspeed_memory_bitstream:: bitstream;
6
4
use rawspeed_memory_bitstream:: bitstream:: BitOrder ;
@@ -11,6 +9,8 @@ use rawspeed_memory_bitstreamer::bitstreamer::BitStreamerBase;
11
9
use rawspeed_memory_bitstreamer:: bitstreamer:: BitStreamerCacheFillImpl ;
12
10
use rawspeed_memory_bitstreamer:: bitstreamer:: BitStreamerTraits ;
13
11
use rawspeed_memory_endianness:: endianness:: SwapBytes ;
12
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: CopyFromSlice ;
13
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: LoadFromSlice ;
14
14
use rawspeed_memory_variable_length_load:: variable_length_load:: VariableLengthLoad ;
15
15
use rawspeed_std:: coord_common:: RowIndex ;
16
16
use rawspeed_std_ndslice:: array2dref:: Array2DRef ;
Original file line number Diff line number Diff line change @@ -94,38 +94,6 @@ impl_to_ne_bytes!(u16);
94
94
impl_to_ne_bytes ! ( u32 ) ;
95
95
impl_to_ne_bytes ! ( u64 ) ;
96
96
97
- pub trait CopyFromSlice {
98
- fn copy_from_slice_ ( & mut self , src : & [ u8 ] ) ;
99
- }
100
-
101
- impl CopyFromSlice for [ u8 ] {
102
- #[ inline]
103
- fn copy_from_slice_ ( & mut self , src : & [ u8 ] ) {
104
- self . copy_from_slice ( src) ;
105
- }
106
- }
107
-
108
- pub trait LoadFromSlice < T >
109
- where
110
- T : Default + core:: ops:: IndexMut < core:: ops:: RangeFull > ,
111
- <T as core:: ops:: Index < core:: ops:: RangeFull > >:: Output : CopyFromSlice ,
112
- {
113
- fn load_from_slice ( & self ) -> T ;
114
- }
115
-
116
- impl < T > LoadFromSlice < T > for [ u8 ]
117
- where
118
- T : Default + core:: ops:: IndexMut < core:: ops:: RangeFull > ,
119
- <T as core:: ops:: Index < core:: ops:: RangeFull > >:: Output : CopyFromSlice ,
120
- {
121
- #[ inline]
122
- fn load_from_slice ( & self ) -> T {
123
- let mut out: T = Default :: default ( ) ;
124
- out[ ..] . copy_from_slice_ ( self ) ;
125
- out
126
- }
127
- }
128
-
129
97
pub trait FromNeBytes {
130
98
type Output ;
131
99
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ rawspeed-memory-bitstream = { path = "../bitstream" }
18
18
rawspeed-memory-endianness = { path = " ../endianness" }
19
19
rawspeed-memory-bitstreamcache = { path = " ../bitstreamcache" }
20
20
rawspeed-memory-variable_length_load = { path = " ../variable_length_load" }
21
+ rawspeed-memory-fixed_length_load = { path = " ../fixed_length_load" }
21
22
22
23
[lib ]
23
24
path = " mod.rs"
Original file line number Diff line number Diff line change 1
1
use core:: marker:: PhantomData ;
2
2
use core:: ops:: RangeFull ;
3
- use rawspeed_common:: bit_transmutation:: CopyFromSlice ;
4
3
use rawspeed_common:: bit_transmutation:: FromNeBytes ;
5
- use rawspeed_common:: bit_transmutation:: LoadFromSlice ;
6
4
use rawspeed_common:: common:: Bitwidth ;
7
5
use rawspeed_memory_bitstream:: bitstream:: BitOrder ;
8
6
use rawspeed_memory_bitstream:: bitstream:: BitOrderTrait ;
9
7
use rawspeed_memory_bitstream:: bitstream:: BitStreamTraits ;
10
8
use rawspeed_memory_bitstreamcache:: bitstreamcache:: BitStreamCache ;
11
9
use rawspeed_memory_endianness:: endianness:: SwapBytes ;
12
10
use rawspeed_memory_endianness:: endianness:: get_host_endianness;
11
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: CopyFromSlice ;
12
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: LoadFromSlice ;
13
13
use rawspeed_memory_variable_length_load:: variable_length_load:: VariableLengthLoad ;
14
14
15
15
pub trait BitStreamerTraits {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ workspace = true
14
14
15
15
[dependencies ]
16
16
rawspeed-memory-endianness = { path = " ../endianness" }
17
+ rawspeed-memory-fixed_length_load = { path = " ../fixed_length_load" }
17
18
rawspeed-common = { path = " ../../common" }
18
19
19
20
[lib ]
Original file line number Diff line number Diff line change 1
- use rawspeed_common:: bit_transmutation:: CopyFromSlice ;
2
1
use rawspeed_common:: bit_transmutation:: FromBits ;
3
2
use rawspeed_common:: bit_transmutation:: FromNeBytes ;
4
- use rawspeed_common:: bit_transmutation:: LoadFromSlice ;
5
3
use rawspeed_common:: bit_transmutation:: ToBits ;
6
4
use rawspeed_common:: bit_transmutation:: ToNeBytes ;
7
5
use rawspeed_memory_endianness:: endianness:: Endianness ;
8
6
use rawspeed_memory_endianness:: endianness:: SwapBytes ;
9
7
use rawspeed_memory_endianness:: endianness:: get_host_endianness;
8
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: CopyFromSlice ;
9
+ use rawspeed_memory_fixed_length_load:: fixed_length_load:: LoadFromSlice ;
10
10
11
11
pub struct ByteStreamer < ' a > {
12
12
slice : & ' a [ u8 ] ,
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " rawspeed-memory-fixed_length_load"
3
+ version.workspace = true
4
+ authors.workspace = true
5
+ edition.workspace = true
6
+ rust-version.workspace = true
7
+ documentation.workspace = true
8
+ homepage.workspace = true
9
+ repository.workspace = true
10
+ license.workspace = true
11
+
12
+ [lints ]
13
+ workspace = true
14
+
15
+ [dependencies ]
16
+
17
+ [lib ]
18
+ path = " mod.rs"
Original file line number Diff line number Diff line change
1
+ pub trait CopyFromSlice {
2
+ fn copy_from_slice_ ( & mut self , src : & [ u8 ] ) ;
3
+ }
4
+
5
+ impl CopyFromSlice for [ u8 ] {
6
+ #[ inline]
7
+ fn copy_from_slice_ ( & mut self , src : & [ u8 ] ) {
8
+ self . copy_from_slice ( src) ;
9
+ }
10
+ }
11
+
12
+ pub trait LoadFromSlice < T >
13
+ where
14
+ T : Default + core:: ops:: IndexMut < core:: ops:: RangeFull > ,
15
+ <T as core:: ops:: Index < core:: ops:: RangeFull > >:: Output : CopyFromSlice ,
16
+ {
17
+ fn load_from_slice ( & self ) -> T ;
18
+ }
19
+
20
+ impl < T > LoadFromSlice < T > for [ u8 ]
21
+ where
22
+ T : Default + core:: ops:: IndexMut < core:: ops:: RangeFull > ,
23
+ <T as core:: ops:: Index < core:: ops:: RangeFull > >:: Output : CopyFromSlice ,
24
+ {
25
+ #[ inline]
26
+ fn load_from_slice ( & self ) -> T {
27
+ let mut out: T = Default :: default ( ) ;
28
+ out[ ..] . copy_from_slice_ ( self ) ;
29
+ out
30
+ }
31
+ }
32
+
33
+ #[ cfg( test) ]
34
+ mod tests;
You can’t perform that action at this time.
0 commit comments