@@ -2023,6 +2023,7 @@ fn link_host_functions(linker: &mut Linker<ClarityWasmContext>) -> Result<(), Er
2023
2023
link_principal_of_fn ( linker) ?;
2024
2024
link_save_constant_fn ( linker) ?;
2025
2025
link_load_constant_fn ( linker) ?;
2026
+ link_skip_list ( linker) ?;
2026
2027
2027
2028
link_log ( linker)
2028
2029
}
@@ -6068,6 +6069,44 @@ fn link_load_constant_fn(linker: &mut Linker<ClarityWasmContext>) -> Result<(),
6068
6069
} )
6069
6070
}
6070
6071
6072
+ fn link_skip_list < T > ( linker : & mut Linker < T > ) -> Result < ( ) , Error > {
6073
+ linker
6074
+ . func_wrap (
6075
+ "clarity" ,
6076
+ "skip_list" ,
6077
+ |mut caller : Caller < ' _ , T > , offset_beg : i32 , offset_end : i32 | {
6078
+ let memory = caller
6079
+ . get_export ( "memory" )
6080
+ . and_then ( |export| export. into_memory ( ) )
6081
+ . ok_or ( Error :: Wasm ( WasmError :: MemoryNotFound ) ) ?;
6082
+
6083
+ // we will read the remaining serialized buffer here, and start it with the list type prefix
6084
+ let mut serialized_buffer = vec ! [ 0u8 ; ( offset_end - offset_beg) as usize + 1 ] ;
6085
+ serialized_buffer[ 0 ] = super :: types:: serialization:: TypePrefix :: List as u8 ;
6086
+ memory
6087
+ . read (
6088
+ & mut caller,
6089
+ offset_beg as usize ,
6090
+ & mut serialized_buffer[ 1 ..] ,
6091
+ )
6092
+ . map_err ( |e| Error :: Wasm ( WasmError :: Runtime ( e. into ( ) ) ) ) ?;
6093
+
6094
+ match Value :: deserialize_read_count ( & mut serialized_buffer. as_slice ( ) , None , false )
6095
+ {
6096
+ Ok ( ( _, bytes_read) ) => Ok ( offset_beg + bytes_read as i32 - 1 ) ,
6097
+ Err ( _) => Ok ( 0 ) ,
6098
+ }
6099
+ } ,
6100
+ )
6101
+ . map ( |_| ( ) )
6102
+ . map_err ( |e| {
6103
+ Error :: Wasm ( WasmError :: UnableToLinkHostFunction (
6104
+ "skip_list" . to_string ( ) ,
6105
+ e,
6106
+ ) )
6107
+ } )
6108
+ }
6109
+
6071
6110
/// Link host-interface function, `log`, into the Wasm module.
6072
6111
/// This function is used for debugging the Wasm, and should not be called in
6073
6112
/// production.
0 commit comments