mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-12 10:37:11 +00:00
feat(interface-types) Rename from_values
to from_interface_values
.
This commit is contained in:
parent
7b182416df
commit
8868d640fa
@ -221,7 +221,7 @@ mod tests {
|
|||||||
use crate::interpreter::{
|
use crate::interpreter::{
|
||||||
instructions::tests::{Export, Instance, LocalImport, Memory, MemoryView},
|
instructions::tests::{Export, Instance, LocalImport, Memory, MemoryView},
|
||||||
stack::Stackable,
|
stack::Stackable,
|
||||||
wasm::values::{from_values, InterfaceType, InterfaceValue},
|
wasm::values::{from_interface_values, InterfaceType, InterfaceValue},
|
||||||
Instruction, Interpreter,
|
Instruction, Interpreter,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -263,7 +263,7 @@ mod tests {
|
|||||||
y: i64,
|
y: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
let record: T = from_values(stack.as_slice()).unwrap();
|
let record: T = from_interface_values(stack.as_slice()).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
record,
|
record,
|
||||||
|
@ -16,7 +16,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Deserialize a set of `InterfaceValue`s to a type `T` that
|
/// Deserialize a set of `InterfaceValue`s to a type `T` that
|
||||||
/// implements `Deserialize`.
|
/// implements the `Deserialize` trait.
|
||||||
///
|
///
|
||||||
/// This is not a requirement to use WIT, but Serde provides an even
|
/// This is not a requirement to use WIT, but Serde provides an even
|
||||||
/// nicer API to the user to rebuild its complex types from WIT
|
/// nicer API to the user to rebuild its complex types from WIT
|
||||||
@ -27,7 +27,7 @@ use std::{
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use wasmer_interface_types::interpreter::wasm::values::{
|
/// use wasmer_interface_types::interpreter::wasm::values::{
|
||||||
/// InterfaceValue,
|
/// InterfaceValue,
|
||||||
/// from_values,
|
/// from_interface_values,
|
||||||
/// };
|
/// };
|
||||||
/// use serde::Deserialize;
|
/// use serde::Deserialize;
|
||||||
///
|
///
|
||||||
@ -46,7 +46,7 @@ use std::{
|
|||||||
/// InterfaceValue::Record(vec![InterfaceValue::I32(1), InterfaceValue::I64(2)]),
|
/// InterfaceValue::Record(vec![InterfaceValue::I32(1), InterfaceValue::I64(2)]),
|
||||||
/// InterfaceValue::F32(3.),
|
/// InterfaceValue::F32(3.),
|
||||||
/// ];
|
/// ];
|
||||||
/// let t: T = from_values(&values).unwrap();
|
/// let t: T = from_interface_values(&values).unwrap();
|
||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// t,
|
/// t,
|
||||||
@ -57,7 +57,7 @@ use std::{
|
|||||||
/// }
|
/// }
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn from_values<'a, T>(values: &'a [InterfaceValue]) -> Result<T, Error>
|
pub fn from_interface_values<'a, T>(values: &'a [InterfaceValue]) -> Result<T, Error>
|
||||||
where
|
where
|
||||||
T: Deserialize<'a>,
|
T: Deserialize<'a>,
|
||||||
{
|
{
|
||||||
@ -475,7 +475,7 @@ mod tests {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from(value: Vec<InterfaceValue>) -> Result<Self, Self::Error> {
|
fn try_from(value: Vec<InterfaceValue>) -> Result<Self, Self::Error> {
|
||||||
from_values(&value)
|
from_interface_values(&value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ mod tests {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from(value: &Vec<InterfaceValue>) -> Result<Self, Self::Error> {
|
fn try_from(value: &Vec<InterfaceValue>) -> Result<Self, Self::Error> {
|
||||||
from_values(value)
|
from_interface_values(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -640,7 +640,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let v = vec![InterfaceValue::String("foo".to_string())];
|
let v = vec![InterfaceValue::String("foo".to_string())];
|
||||||
let input: S = from_values(&v).unwrap();
|
let input: S = from_interface_values(&v).unwrap();
|
||||||
let output = S { x: "foo" };
|
let output = S { x: "foo" };
|
||||||
|
|
||||||
assert_eq!(input, output);
|
assert_eq!(input, output);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user