xxchan edited issue #6645:
I have WIT definitions like this:
default world w { export abc: self.abc } interface abc { type column = list<u8> record record-batch { schema: schema, // columns: list<array-data>, columns: list<column>, // row-count: u32, } enum data-type { dt-i16, dt-i32, dt-i64, dt-bool, dt-string, } record field { name: string, data-type: data-type, } record schema { fields: list<field>, } enum eval-errno { err1 } eval: func(batch: record-batch) -> result<column, eval-errno> }
wasmtime generates
RecordBatch<'a>
,#[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct Field<'a> { #[component(name = "name")] pub name: &'a str, #[component(name = "data-type")] pub data_type: DataType, } #[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct Schema<'a> { #[component(name = "fields")] pub fields: &'a [Field<'a>], } pub type Column = Vec<u8>; #[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct RecordBatch<'a> { #[component(name = "schema")] pub schema: Schema<'a>, #[component(name = "columns")] pub columns: &'a [&'a Column], }
while wit-bindgen generates
RecordBatch
#[derive(Clone)] pub struct Field { pub name:wit_bindgen::rt::string::String,pub data_type:DataType, } #[derive(Clone)] pub struct Schema { pub fields:wit_bindgen::rt::vec::Vec::<Field>, } pub type Column = wit_bindgen::rt::vec::Vec<u8>; #[derive(Clone)] pub struct RecordBatch { pub schema: Schema, pub columns: wit_bindgen::rt::vec::Vec<Column>, }
Is this expected? I don't quite understand the reason and the lifetimes are not easy to work with :oh_no:
xxchan commented on issue #6645:
I'm using
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "5b93cdb", features = [ "component-model", ] } wit-bindgen = "0.6.0"
alexcrichton commented on issue #6645:
This is an old feature which I don't think makes sense any more and I believe @dicej is working on making the bindgen more like wit-bindgen.
dicej commented on issue #6645:
This is the PR: https://github.com/bytecodealliance/wasmtime/pull/6648. It actually makes
wasmtime-wit-bindgen
_less_ likewit-bindgen
, but I'm planning to make another PR for the latter to make them behave the same if we have consensus on what that behavior should be.
xxchan commented on issue #6645:
Thanks for your work!
xxchan closed issue #6645:
I have WIT definitions like this:
default world w { export abc: self.abc } interface abc { type column = list<u8> record record-batch { schema: schema, // columns: list<array-data>, columns: list<column>, // row-count: u32, } enum data-type { dt-i16, dt-i32, dt-i64, dt-bool, dt-string, } record field { name: string, data-type: data-type, } record schema { fields: list<field>, } enum eval-errno { err1 } eval: func(batch: record-batch) -> result<column, eval-errno> }
wasmtime generates
RecordBatch<'a>
,#[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct Field<'a> { #[component(name = "name")] pub name: &'a str, #[component(name = "data-type")] pub data_type: DataType, } #[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct Schema<'a> { #[component(name = "fields")] pub fields: &'a [Field<'a>], } pub type Column = Vec<u8>; #[derive(wasmtime::component::ComponentType, wasmtime::component::Lower)] #[component(record)] #[derive(Clone)] pub struct RecordBatch<'a> { #[component(name = "schema")] pub schema: Schema<'a>, #[component(name = "columns")] pub columns: &'a [&'a Column], }
while wit-bindgen generates
RecordBatch
#[derive(Clone)] pub struct Field { pub name:wit_bindgen::rt::string::String,pub data_type:DataType, } #[derive(Clone)] pub struct Schema { pub fields:wit_bindgen::rt::vec::Vec::<Field>, } pub type Column = wit_bindgen::rt::vec::Vec<u8>; #[derive(Clone)] pub struct RecordBatch { pub schema: Schema, pub columns: wit_bindgen::rt::vec::Vec<Column>, }
Is this expected? I don't quite understand the reason and the lifetimes are not easy to work with :oh_no:
Last updated: Nov 22 2024 at 16:03 UTC