(&mut self, resolve: &Resolve, world: WorldId)
| 878 | } |
| 879 | |
| 880 | fn build_world_struct(&mut self, resolve: &Resolve, world: WorldId) { |
| 881 | let wt = self.wasmtime_path(); |
| 882 | let world_name = &resolve.worlds[world].name; |
| 883 | let camel = to_rust_upper_camel_case(&world_name); |
| 884 | uwriteln!( |
| 885 | self.src, |
| 886 | " |
| 887 | /// Auto-generated bindings for a pre-instantiated version of a |
| 888 | /// component which implements the world `{world_name}`. |
| 889 | /// |
| 890 | /// This structure is created through [`{camel}Pre::new`] which |
| 891 | /// takes a [`InstancePre`]({wt}::component::InstancePre) that |
| 892 | /// has been created through a [`Linker`]({wt}::component::Linker). |
| 893 | /// |
| 894 | /// For more information see [`{camel}`] as well. |
| 895 | pub struct {camel}Pre<T: 'static> {{ |
| 896 | instance_pre: {wt}::component::InstancePre<T>, |
| 897 | indices: {camel}Indices, |
| 898 | }} |
| 899 | |
| 900 | impl<T: 'static> Clone for {camel}Pre<T> {{ |
| 901 | fn clone(&self) -> Self {{ |
| 902 | Self {{ |
| 903 | instance_pre: self.instance_pre.clone(), |
| 904 | indices: self.indices.clone(), |
| 905 | }} |
| 906 | }} |
| 907 | }} |
| 908 | |
| 909 | impl<_T: 'static> {camel}Pre<_T> {{ |
| 910 | /// Creates a new copy of `{camel}Pre` bindings which can then |
| 911 | /// be used to instantiate into a particular store. |
| 912 | /// |
| 913 | /// This method may fail if the component behind `instance_pre` |
| 914 | /// does not have the required exports. |
| 915 | pub fn new(instance_pre: {wt}::component::InstancePre<_T>) -> {wt}::Result<Self> {{ |
| 916 | let indices = {camel}Indices::new(&instance_pre)?; |
| 917 | Ok(Self {{ instance_pre, indices }}) |
| 918 | }} |
| 919 | |
| 920 | pub fn engine(&self) -> &{wt}::Engine {{ |
| 921 | self.instance_pre.engine() |
| 922 | }} |
| 923 | |
| 924 | pub fn instance_pre(&self) -> &{wt}::component::InstancePre<_T> {{ |
| 925 | &self.instance_pre |
| 926 | }} |
| 927 | |
| 928 | /// Instantiates a new instance of [`{camel}`] within the |
| 929 | /// `store` provided. |
| 930 | /// |
| 931 | /// This function will use `self` as the pre-instantiated |
| 932 | /// instance to perform instantiation. Afterwards the preloaded |
| 933 | /// indices in `self` are used to lookup all exports on the |
| 934 | /// resulting instance. |
| 935 | pub fn instantiate( |
| 936 | &self, |
| 937 | mut store: impl {wt}::AsContextMut<Data = _T>, |
no test coverage detected