mirror of
https://github.com/fluencelabs/interface-types
synced 2025-06-23 19:51:39 +00:00
use u32 instead of usize for memory offsets/sizes to avoid i32->usize casts (#16)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "it-memory-traits"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Fluence Labs"]
|
||||
description = "Defines traits that IT uses for accessing memory"
|
||||
edition = "2018"
|
||||
|
@ -20,8 +20,8 @@ use thiserror::Error as ThisError;
|
||||
pub enum MemoryAccessError {
|
||||
#[error("Out-of-bound Wasm memory access: offset {offset}, size {size}, while memory_size {memory_size}")]
|
||||
OutOfBounds {
|
||||
offset: usize,
|
||||
size: usize,
|
||||
memory_size: usize,
|
||||
offset: u32,
|
||||
size: u32,
|
||||
memory_size: u32,
|
||||
},
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ pub trait SequentialReader {
|
||||
}
|
||||
|
||||
pub trait SequentialWriter {
|
||||
fn start_offset(&self) -> usize;
|
||||
fn start_offset(&self) -> u32;
|
||||
|
||||
// specialization of write_array for u8
|
||||
fn write_u8(&self, value: u8);
|
||||
@ -65,17 +65,9 @@ pub trait SequentialMemoryView<'s> {
|
||||
type SR: SequentialReader + 's;
|
||||
type SW: SequentialWriter + 's;
|
||||
|
||||
fn sequential_writer(
|
||||
&'s self,
|
||||
offset: usize,
|
||||
size: usize,
|
||||
) -> Result<Self::SW, MemoryAccessError>;
|
||||
fn sequential_writer(&'s self, offset: u32, size: u32) -> Result<Self::SW, MemoryAccessError>;
|
||||
|
||||
fn sequential_reader(
|
||||
&'s self,
|
||||
offset: usize,
|
||||
size: usize,
|
||||
) -> Result<Self::SR, MemoryAccessError>;
|
||||
fn sequential_reader(&'s self, offset: u32, size: u32) -> Result<Self::SR, MemoryAccessError>;
|
||||
}
|
||||
|
||||
pub trait Memory<View>
|
||||
|
Reference in New Issue
Block a user