Skip to content

Commit 81fb4d9

Browse files
committed
Remove generics from SupportedParameterType and SupportedReturnType traits
Signed-off-by: Jorge Prendes <[email protected]>
1 parent a56ea7a commit 81fb4d9

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/hyperlight_host/src/func/host_functions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ macro_rules! impl_host_function {
8787
impl<R $(, $P)*, F> HostFunction<R, ($($P,)*)> for Arc<Mutex<F>>
8888
where
8989
F: FnMut($($P),*) -> Result<R> + Send + 'static,
90-
$($P: SupportedParameterType<$P> + Clone,)*
91-
R: SupportedReturnType<R>,
90+
$($P: SupportedParameterType + Clone,)*
91+
R: SupportedReturnType,
9292
{
9393
/// Register the host function with the given name in the sandbox.
9494
#[instrument(
@@ -162,8 +162,8 @@ macro_rules! impl_host_function {
162162
) -> Result<()>
163163
where
164164
T: FnMut($($P),*) -> Result<R> + Send + 'static,
165-
$($P: SupportedParameterType<$P> + Clone,)*
166-
R: SupportedReturnType<R>,
165+
$($P: SupportedParameterType + Clone,)*
166+
R: SupportedReturnType,
167167
{
168168
const N: usize = impl_host_function!(@count $($P),*);
169169
let cloned = self_.clone();

src/hyperlight_host/src/func/param_type.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ use crate::{log_then_return, Result};
2424
/// valid Hyperlight parameter type.
2525
///
2626
/// For each parameter type Hyperlight supports in host functions, we
27-
/// provide an implementation for `SupportedParameterType<SupportedType>`
28-
pub trait SupportedParameterType<T> {
27+
/// provide an implementation for `SupportedParameterType`
28+
pub trait SupportedParameterType: Sized {
2929
/// Get the underlying Hyperlight parameter type representing this
3030
/// `SupportedParameterType`
3131
fn get_hyperlight_type() -> ParameterType;
3232
/// Get the underling Hyperlight parameter value representing this
3333
/// `SupportedParameterType`
3434
fn get_hyperlight_value(&self) -> ParameterValue;
3535
/// Get the actual inner value of this `SupportedParameterType`
36-
fn get_inner(a: ParameterValue) -> Result<T>;
36+
fn get_inner(a: ParameterValue) -> Result<Self>;
3737
}
3838

3939
// We can then implement these traits for each type that Hyperlight supports as a parameter or return type
40-
impl SupportedParameterType<String> for String {
40+
impl SupportedParameterType for String {
4141
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
4242
fn get_hyperlight_type() -> ParameterType {
4343
ParameterType::String
@@ -59,7 +59,7 @@ impl SupportedParameterType<String> for String {
5959
}
6060
}
6161

62-
impl SupportedParameterType<i32> for i32 {
62+
impl SupportedParameterType for i32 {
6363
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
6464
fn get_hyperlight_type() -> ParameterType {
6565
ParameterType::Int
@@ -81,7 +81,7 @@ impl SupportedParameterType<i32> for i32 {
8181
}
8282
}
8383

84-
impl SupportedParameterType<u32> for u32 {
84+
impl SupportedParameterType for u32 {
8585
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
8686
fn get_hyperlight_type() -> ParameterType {
8787
ParameterType::UInt
@@ -103,7 +103,7 @@ impl SupportedParameterType<u32> for u32 {
103103
}
104104
}
105105

106-
impl SupportedParameterType<i64> for i64 {
106+
impl SupportedParameterType for i64 {
107107
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
108108
fn get_hyperlight_type() -> ParameterType {
109109
ParameterType::Long
@@ -125,7 +125,7 @@ impl SupportedParameterType<i64> for i64 {
125125
}
126126
}
127127

128-
impl SupportedParameterType<u64> for u64 {
128+
impl SupportedParameterType for u64 {
129129
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
130130
fn get_hyperlight_type() -> ParameterType {
131131
ParameterType::ULong
@@ -147,7 +147,7 @@ impl SupportedParameterType<u64> for u64 {
147147
}
148148
}
149149

150-
impl SupportedParameterType<bool> for bool {
150+
impl SupportedParameterType for bool {
151151
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
152152
fn get_hyperlight_type() -> ParameterType {
153153
ParameterType::Bool
@@ -169,7 +169,7 @@ impl SupportedParameterType<bool> for bool {
169169
}
170170
}
171171

172-
impl SupportedParameterType<Vec<u8>> for Vec<u8> {
172+
impl SupportedParameterType for Vec<u8> {
173173
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
174174
fn get_hyperlight_type() -> ParameterType {
175175
ParameterType::VecBytes

src/hyperlight_host/src/func/ret_type.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ use crate::HyperlightError::ReturnValueConversionFailure;
2121
use crate::{log_then_return, Result};
2222

2323
/// This is a marker trait that is used to indicate that a type is a valid Hyperlight return type.
24-
pub trait SupportedReturnType<T> {
24+
pub trait SupportedReturnType: Sized {
2525
/// Gets the return type of the supported return value
2626
fn get_hyperlight_type() -> ReturnType;
2727

2828
/// Gets the value of the supported return value
2929
fn get_hyperlight_value(&self) -> ReturnValue;
3030

3131
/// Gets the inner value of the supported return type
32-
fn get_inner(a: ReturnValue) -> Result<T>;
32+
fn get_inner(a: ReturnValue) -> Result<Self>;
3333
}
3434

35-
impl SupportedReturnType<()> for () {
35+
impl SupportedReturnType for () {
3636
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
3737
fn get_hyperlight_type() -> ReturnType {
3838
ReturnType::Void
@@ -54,7 +54,7 @@ impl SupportedReturnType<()> for () {
5454
}
5555
}
5656

57-
impl SupportedReturnType<String> for String {
57+
impl SupportedReturnType for String {
5858
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
5959
fn get_hyperlight_type() -> ReturnType {
6060
ReturnType::String
@@ -76,7 +76,7 @@ impl SupportedReturnType<String> for String {
7676
}
7777
}
7878

79-
impl SupportedReturnType<i32> for i32 {
79+
impl SupportedReturnType for i32 {
8080
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
8181
fn get_hyperlight_type() -> ReturnType {
8282
ReturnType::Int
@@ -98,7 +98,7 @@ impl SupportedReturnType<i32> for i32 {
9898
}
9999
}
100100

101-
impl SupportedReturnType<u32> for u32 {
101+
impl SupportedReturnType for u32 {
102102
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
103103
fn get_hyperlight_type() -> ReturnType {
104104
ReturnType::UInt
@@ -120,7 +120,7 @@ impl SupportedReturnType<u32> for u32 {
120120
}
121121
}
122122

123-
impl SupportedReturnType<i64> for i64 {
123+
impl SupportedReturnType for i64 {
124124
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
125125
fn get_hyperlight_type() -> ReturnType {
126126
ReturnType::Long
@@ -142,7 +142,7 @@ impl SupportedReturnType<i64> for i64 {
142142
}
143143
}
144144

145-
impl SupportedReturnType<u64> for u64 {
145+
impl SupportedReturnType for u64 {
146146
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
147147
fn get_hyperlight_type() -> ReturnType {
148148
ReturnType::ULong
@@ -164,7 +164,7 @@ impl SupportedReturnType<u64> for u64 {
164164
}
165165
}
166166

167-
impl SupportedReturnType<bool> for bool {
167+
impl SupportedReturnType for bool {
168168
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
169169
fn get_hyperlight_type() -> ReturnType {
170170
ReturnType::Bool
@@ -186,7 +186,7 @@ impl SupportedReturnType<bool> for bool {
186186
}
187187
}
188188

189-
impl SupportedReturnType<Vec<u8>> for Vec<u8> {
189+
impl SupportedReturnType for Vec<u8> {
190190
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
191191
fn get_hyperlight_type() -> ReturnType {
192192
ReturnType::VecBytes

0 commit comments

Comments
 (0)