thegraph-runtime: Implement FromAscObj slices with 32 elements
@@ -21,6 +21,14 @@ impl<T: AscValue> FromAscObj<ArrayBuffer<T>> for Vec<T> {
}
}
+impl<T: AscValue> FromAscObj<ArrayBuffer<T>> for [T; 32] {
+ fn from_asc_obj<H: AscHeap>(array_buffer: ArrayBuffer<T>, _: &H) -> Self {
+ let mut array: [T; 32] = [T::default(); 32];
+ array.copy_from_slice(&array_buffer.content);
+ array
+ }
+}
+
impl<T: AscValue> FromAscObj<ArrayBuffer<T>> for [T; 20] {
fn from_asc_obj<H: AscHeap>(array_buffer: ArrayBuffer<T>, _: &H) -> Self {
let mut array: [T; 20] = [T::default(); 20];
@@ -49,6 +57,14 @@ impl<T: AscValue> FromAscObj<TypedArray<T>> for Vec<T> {
}
}
+impl<T: AscValue> FromAscObj<TypedArray<T>> for [T; 32] {
+ fn from_asc_obj<H: AscHeap>(typed_array: TypedArray<T>, heap: &H) -> Self {
+ let mut array: [T; 32] = [T::default(); 32];
+ array.copy_from_slice(&typed_array.get_buffer(heap).content);
+ array
+ }
+}
+
impl<T: AscValue> FromAscObj<TypedArray<T>> for [T; 20] {
fn from_asc_obj<H: AscHeap>(typed_array: TypedArray<T>, heap: &H) -> Self {
let mut array: [T; 20] = [T::default(); 20];
