Skip to content

Commit 5208cfe

Browse files
authored
make socket component example work (#624)
* make socket component example work Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> * bump Cargo.lock for witguest Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> --------- Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 6e20211 commit 5208cfe

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

src/hyperlight_component_util/src/rtypes.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
386386
};
387387
quote! {
388388
#derives
389-
#[derive(Debug, Clone, PartialEq)]
389+
#[derive(Debug)]
390390
pub struct #id #vs { #toks }
391391
}
392392
}
@@ -444,7 +444,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
444444
};
445445
quote! {
446446
#derives
447-
#[derive(Debug, Clone, PartialEq)]
447+
#[derive(Debug)]
448448
pub enum #id #vs { #toks }
449449
}
450450
}
@@ -471,7 +471,6 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
471471
#[derive(::wasmtime::component::ComponentType)]
472472
#[derive(::wasmtime::component::Lift)]
473473
#[derive(::wasmtime::component::Lower)]
474-
#[derive(::core::marker::Copy)]
475474
#[component(enum)]
476475
#[repr(u8)] // todo: should this always be u8?
477476
}
@@ -480,7 +479,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
480479
};
481480
quote! {
482481
#derives
483-
#[derive(Debug, Clone, PartialEq)]
482+
#[derive(Debug, Copy, Clone, PartialEq)]
484483
pub enum #id #vs { #toks }
485484
}
486485
}

src/hyperlight_host/tests/wit_test.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,45 @@ mod bindings {
2626
hyperlight_component_macro::host_bindgen!("../tests/rust_guests/witguest/interface.wasm");
2727
}
2828

29+
use bindings::test::wit::roundtrip::{Testrecord, Testvariant};
2930
use bindings::*;
3031

32+
impl PartialEq for Testrecord {
33+
fn eq(&self, other: &Self) -> bool {
34+
self.contents == other.contents && self.length == other.length
35+
}
36+
}
37+
38+
impl PartialEq for Testvariant {
39+
fn eq(&self, other: &Self) -> bool {
40+
match (self, other) {
41+
(Testvariant::VariantA, Testvariant::VariantA) => true,
42+
(Testvariant::VariantB(s1), Testvariant::VariantB(s2)) => s1 == s2,
43+
(Testvariant::VariantC(c1), Testvariant::VariantC(c2)) => c1 == c2,
44+
_ => false,
45+
}
46+
}
47+
}
48+
49+
impl Clone for Testrecord {
50+
fn clone(&self) -> Self {
51+
Self {
52+
contents: self.contents.clone(),
53+
length: self.length,
54+
}
55+
}
56+
}
57+
58+
impl Clone for Testvariant {
59+
fn clone(&self) -> Self {
60+
match self {
61+
Self::VariantA => Self::VariantA,
62+
Self::VariantB(s) => Self::VariantB(s.clone()),
63+
Self::VariantC(c) => Self::VariantC(*c),
64+
}
65+
}
66+
}
67+
3168
struct Host {}
3269

3370
impl test::wit::Roundtrip for Host {

src/tests/rust_guests/witguest/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)