Skip to content

Commit

Permalink
Merge branch 'main' into test-serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mpwarres authored Dec 2, 2024
2 parents a7b5055 + 597634d commit c6acd5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ jobs:
run: |
curl -OL https://static.rust-lang.org/rustup/rustup-init.sh
chmod +x ./rustup-init.sh
./rustup-init.sh -y --default-toolchain 1.64.0
./rustup-init.sh -y --default-toolchain 1.65.0
rm rustup-init.sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Update Rust
run: |
rustup toolchain install 1.64.0 --component clippy --component rustfmt
rustup default 1.64.0
rustup toolchain install 1.65.0 --component clippy --component rustfmt
rustup default 1.65.0
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasi
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "proxy-wasm"
version = "0.2.3-dev"
authors = ["Piotr Sikora <[email protected]>"]
rust-version = "1.64"
rust-version = "1.65"
description = "WebAssembly for Proxies"
readme = "README.md"
license = "Apache-2.0"
Expand Down
16 changes: 8 additions & 8 deletions src/hostcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ pub fn get_map(map_type: MapType) -> Result<Vec<(String, String)>, Status> {
match proxy_get_header_map_pairs(map_type, &mut return_data, &mut return_size) {
Status::Ok => {
if !return_data.is_null() {
let serialized_map = Vec::from_raw_parts(return_data, return_size, return_size);
Ok(utils::deserialize_map(&serialized_map))
let serialized_map = std::slice::from_raw_parts(return_data, return_size);
Ok(utils::deserialize_map(serialized_map))
} else {
Ok(Vec::new())
}
Expand All @@ -170,8 +170,8 @@ pub fn get_map_bytes(map_type: MapType) -> Result<Vec<(String, Bytes)>, Status>
match proxy_get_header_map_pairs(map_type, &mut return_data, &mut return_size) {
Status::Ok => {
if !return_data.is_null() {
let serialized_map = Vec::from_raw_parts(return_data, return_size, return_size);
Ok(utils::deserialize_map_bytes(&serialized_map))
let serialized_map = std::slice::from_raw_parts(return_data, return_size);
Ok(utils::deserialize_map_bytes(serialized_map))
} else {
Ok(Vec::new())
}
Expand Down Expand Up @@ -1200,11 +1200,11 @@ mod utils {
}

pub(super) fn deserialize_map(bytes: &[u8]) -> Vec<(String, String)> {
let mut map = Vec::new();
if bytes.is_empty() {
return map;
return Vec::new();
}
let size = u32::from_le_bytes(<[u8; 4]>::try_from(&bytes[0..4]).unwrap()) as usize;
let mut map = Vec::with_capacity(size);
let mut p = 4 + size * 8;
for n in 0..size {
let s = 4 + n * 8;
Expand All @@ -1224,11 +1224,11 @@ mod utils {
}

pub(super) fn deserialize_map_bytes(bytes: &[u8]) -> Vec<(String, Bytes)> {
let mut map = Vec::new();
if bytes.is_empty() {
return map;
return Vec::new();
}
let size = u32::from_le_bytes(<[u8; 4]>::try_from(&bytes[0..4]).unwrap()) as usize;
let mut map = Vec::with_capacity(size);
let mut p = 4 + size * 8;
for n in 0..size {
let s = 4 + n * 8;
Expand Down

0 comments on commit c6acd5f

Please sign in to comment.