Windows-rs: Missing methods when updating to 0.4.0 or later

Created on 11 Mar 2021  路  2Comments  路  Source: microsoft/windows-rs

I've bumped this dependency for a crate from version 0.2 to 0.4. After a few minor tweaks to build.rs, I'm getting some missing methods:

error[E0599]: no method named `options` found for struct `SpeechSynthesizer` in the current scope --> src\backends\winrt.rs:280:33 | 280 | let volume = self.synth.options()?.audio_volume()?; | ^^^^^^^ method not found in `SpeechSynthesizer` ... error[E0599]: no function or associated item named `create_from_stream` found for struct `MediaSource` in the current scope --> src\backends\winrt.rs:189:39 | 189 | let source = MediaSource::create_from_stream(stream, content_type)?; | ^^^^^^^^^^^^^^^^^^ function or associated item not found in `MediaSource`

I've got a few more like that. These were valid methods in 0.2, but something seems to be missing in 0.4. I also checked the generated crate docs in at least one case, and the function I was attempting to call was indeed still listed. Am I missing a non-obvious import?

I've pushed my non-functional WIP here. Help welcome.

Thanks!

question

Most helpful comment

Hi Nolan, this is related to an optimization that greatly reduces the amount of code gen and thus build time (#587) but has the effect of eliding methods that refer to types that you don't also import in your build script. I'm going to add a tweak to make this more obvious (#592).

Anyway, in the short term you can just look up the missing methods and find out what types they refer to and then add those types to your build script. For example the options method returns a SpeechSynthesizerOptions and the create_from_stream method has a IRandomAccessStream parameter. You should be able to add these two to your build script to get you going. Something like this:

windows::storage::streams::IRandomAccessStream,
windows::media::speech_synthesis::SpeechSynthesizerOptions,

ILSpy is a great tool for quickly looking up type information. It's a lot faster than Rust docs.

Otherwise you can also look at the published Rust docs. For example, here's the docs for the options method.

All 2 comments

Hi Nolan, this is related to an optimization that greatly reduces the amount of code gen and thus build time (#587) but has the effect of eliding methods that refer to types that you don't also import in your build script. I'm going to add a tweak to make this more obvious (#592).

Anyway, in the short term you can just look up the missing methods and find out what types they refer to and then add those types to your build script. For example the options method returns a SpeechSynthesizerOptions and the create_from_stream method has a IRandomAccessStream parameter. You should be able to add these two to your build script to get you going. Something like this:

windows::storage::streams::IRandomAccessStream,
windows::media::speech_synthesis::SpeechSynthesizerOptions,

ILSpy is a great tool for quickly looking up type information. It's a lot faster than Rust docs.

Otherwise you can also look at the published Rust docs. For example, here's the docs for the options method.

Got it working. Thanks for the quick answer, as always.

Was this page helpful?
0 / 5 - 0 ratings