Skip to content

Commit

Permalink
make into_bytes pub
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Apr 26, 2024
1 parent 9d6b854 commit aec0521
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x/programs/rust/wasmlanche-sdk/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
/// Reconstructs the vec from the pointer with the length given by the store
/// `host_ptr` is encoded using Big Endian as an i64.
#[must_use]
fn into_bytes(ptr: HostPtr) -> Option<Vec<u8>> {
pub fn into_bytes(ptr: HostPtr) -> Option<Vec<u8>> {
GLOBAL_STORE
.with_borrow_mut(|s| s.remove(&(ptr as *const u8)))
.map(|len| unsafe { std::vec::Vec::from_raw_parts(ptr as *mut u8, len, len) })
Expand Down
6 changes: 4 additions & 2 deletions x/programs/rust/wasmlanche-sdk/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ impl Key {

mod host {
use super::{BorshSerialize, Key, Program};
use crate::memory::into_bytes;
use crate::{memory::to_host_ptr, state::Error};
use crate::{
memory::{into_bytes, to_host_ptr},
state::Error,
};

#[link(wasm_import_module = "state")]
extern "C" {
Expand Down

0 comments on commit aec0521

Please sign in to comment.