@@ -50,6 +50,18 @@ impl<'a> ByteAddressableBuffer<'a> {
50
50
buffer_load_intrinsic ( self . data , byte_index)
51
51
}
52
52
53
+ /// Loads an arbitrary type from the buffer. `byte_index` must be a multiple of 4, otherwise,
54
+ /// it will get silently rounded down to the nearest multiple of 4. Bounds checking is not
55
+ /// performed.
56
+ ///
57
+ /// # Safety
58
+ /// This function allows writing a type to an untyped buffer, then reading a different type
59
+ /// from the same buffer, allowing all sorts of safety guarantees to be bypassed (effectively a
60
+ /// transmute). Additionally, bounds checking is not performed.
61
+ pub unsafe fn load_unchecked < T > ( self , byte_index : u32 ) -> T {
62
+ buffer_load_intrinsic ( self . data , byte_index)
63
+ }
64
+
53
65
/// Stores an arbitrary type int the buffer. `byte_index` must be a multiple of 4, otherwise,
54
66
/// it will get silently rounded down to the nearest multiple of 4.
55
67
///
@@ -63,4 +75,16 @@ impl<'a> ByteAddressableBuffer<'a> {
63
75
}
64
76
buffer_store_intrinsic ( self . data , byte_index, value) ;
65
77
}
78
+
79
+ /// Stores an arbitrary type int the buffer. `byte_index` must be a multiple of 4, otherwise,
80
+ /// it will get silently rounded down to the nearest multiple of 4. Bounds checking is not
81
+ /// performed.
82
+ ///
83
+ /// # Safety
84
+ /// This function allows writing a type to an untyped buffer, then reading a different type
85
+ /// from the same buffer, allowing all sorts of safety guarantees to be bypassed (effectively a
86
+ /// transmute). Additionally, bounds checking is not performed.
87
+ pub unsafe fn store_unchecked < T > ( self , byte_index : u32 , value : T ) {
88
+ buffer_store_intrinsic ( self . data , byte_index, value) ;
89
+ }
66
90
}
0 commit comments