Stream: git-wasmtime

Topic: wasmtime / issue #6645 component-model: bindgen generates...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 09:21):

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:

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 09:24):

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"

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 14:40):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 17:51):

dicej commented on issue #6645:

This is the PR: https://github.com/bytecodealliance/wasmtime/pull/6648. It actually makes wasmtime-wit-bindgen _less_ like wit-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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 19:32):

xxchan commented on issue #6645:

Thanks for your work!

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 19:32):

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: Dec 23 2024 at 12:05 UTC