Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/component-macro/tests/codegen/records.wit
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ interface records {
type int-typedef = s32;
type tuple-typedef2 = tuple<int-typedef>;
typedef-inout: func(e: tuple-typedef2) -> s32;

record futures-and-streams {
a: future<u8>,
b: stream<u8>,
c: stream<future<stream>>,
d: future<stream<future>>,
}
}

world the-world {
Expand Down
87 changes: 87 additions & 0 deletions crates/component-macro/tests/expanded/records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,48 @@ pub mod foo {
4 == < TupleTypedef2 as wasmtime::component::ComponentType >::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
pub trait HostWithStore: wasmtime::component::HasData {}
impl<_T: ?Sized> HostWithStore for _T
where
Expand Down Expand Up @@ -711,6 +753,51 @@ pub mod exports {
>::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(
&self,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
#[derive(Clone)]
pub struct Guest {
tuple_arg: wasmtime::component::Func,
Expand Down
87 changes: 87 additions & 0 deletions crates/component-macro/tests/expanded/records_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,48 @@ pub mod foo {
4 == < TupleTypedef2 as wasmtime::component::ComponentType >::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
pub trait HostWithStore: wasmtime::component::HasData + Send {}
impl<_T: ?Sized> HostWithStore for _T
where
Expand Down Expand Up @@ -789,6 +831,51 @@ pub mod exports {
>::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(
&self,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
#[derive(Clone)]
pub struct Guest {
tuple_arg: wasmtime::component::Func,
Expand Down
87 changes: 87 additions & 0 deletions crates/component-macro/tests/expanded/records_concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,48 @@ pub mod foo {
4 == < TupleTypedef2 as wasmtime::component::ComponentType >::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
pub trait HostWithStore: wasmtime::component::HasData + Send {
fn tuple_arg<T: Send>(
accessor: &wasmtime::component::Accessor<T, Self>,
Expand Down Expand Up @@ -722,6 +764,51 @@ pub mod exports {
>::ALIGN32
);
};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
#[component(record)]
pub struct FuturesAndStreams {
#[component(name = "a")]
pub a: wasmtime::component::FutureReader<u8>,
#[component(name = "b")]
pub b: wasmtime::component::StreamReader<u8>,
#[component(name = "c")]
pub c: wasmtime::component::StreamReader<
wasmtime::component::FutureReader<
wasmtime::component::StreamReader<()>,
>,
>,
#[component(name = "d")]
pub d: wasmtime::component::FutureReader<
wasmtime::component::StreamReader<
wasmtime::component::FutureReader<()>,
>,
>,
}
impl core::fmt::Debug for FuturesAndStreams {
fn fmt(
&self,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
f.debug_struct("FuturesAndStreams")
.field("a", &self.a)
.field("b", &self.b)
.field("c", &self.c)
.field("d", &self.d)
.finish()
}
}
const _: () = {
assert!(
16 == < FuturesAndStreams as wasmtime::component::ComponentType
>::SIZE32
);
assert!(
4 == < FuturesAndStreams as wasmtime::component::ComponentType
>::ALIGN32
);
};
#[derive(Clone)]
pub struct Guest {
tuple_arg: wasmtime::component::Func,
Expand Down
Loading