Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: DateTime should implement IntoParam<'_, IReference<DateTime>> #1830

Closed
mbartlett21 opened this issue Jun 20, 2022 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@mbartlett21
Copy link
Contributor

mbartlett21 commented Jun 20, 2022

Which crate is this about?

windows

Crate version

0.37.0

Summary

windows::Foundation::DateTime should implement IntoParam<'_, IReference<DateTime>>, so that it can be passed to HttpRequestHeaderCollection::SetDate.

Toolchain version/configuration

Default host: x86_64-pc-windows-msvc
rustup home: C:\Users_.rustup

installed toolchains

nightly-x86_64-pc-windows-msvc (default)

installed targets for active toolchain

x86_64-pc-windows-msvc

active toolchain

nightly-x86_64-pc-windows-msvc (default)
rustc 1.63.0-nightly (99930ac7f 2022-06-11)

Reproducible example

use std::io;

use windows::{Foundation::DateTime, Web::Http::Headers::HttpRequestHeaderCollection};

pub async fn get_string_async(headers: HttpRequestHeaderCollection) -> io::Result<()> {
    let date_time = DateTime {
        UniversalTime: 1576,
    };

    headers.SetDate(&date_time)?;

    Ok(())
}

Crate manifest

# ...

[dependencies.windows]
version = "0.37"
features = [
    "Foundation",
    "Storage_Streams",
    "Web_Http",
    "Web_Http_Headers",
    "Win32_System_WinRT",
]

Expected behavior

The code compiled

Actual behavior

error[E0277]: the trait bound `&DateTime: IntoParam<'_, IReference<DateTime>>` is not satisfied
    --> testing\src\main.rs:10:21
     |
10   |     headers.SetDate(&date_time)?;
     |             ------- ^^^^^^^^^^ the trait `IntoParam<'_, IReference<DateTime>>` is not implemented for `&DateTime`
     |             |
     |             required by a bound introduced by this call
     |
     = help: the following other types implement trait `IntoParam<'a, T>`:
               <&'a AppDataPaths as IntoParam<'a, IInspectable>>
               <&'a AppDataPaths as IntoParam<'a, IUnknown>>
               <&'a ApplicationData as IntoParam<'a, IInspectable>>
               <&'a ApplicationData as IntoParam<'a, IUnknown>>
               <&'a ApplicationDataContainer as IntoParam<'a, IInspectable>>
               <&'a ApplicationDataContainer as IntoParam<'a, IUnknown>>
               <&'a Buffer as IntoParam<'a, IInspectable>>
               <&'a Buffer as IntoParam<'a, IUnknown>>
             and 970 others
note: required by a bound in `HttpRequestHeaderCollection::SetDate`
    --> C:\Users\_\.cargo\registry\src\github.com-1ecc6299db9ec823\windows-0.37.0\src\Windows\Web\Http\Headers\mod.rs:6784:32
     |
6784 | ...aram0: ::windows::core::IntoParam<'a, super::super::super::Foundation::IReference<super::super::super::Foundation::DateTime>>>(&self, ...
     |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `HttpRequestHeaderCollection::SetDate`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `testing` due to previous error

Additional comments

Is there anything that I can use without having to implement all 37 methods of IReference myself?

@mbartlett21 mbartlett21 added the bug Something isn't working label Jun 20, 2022
@kennykerr kennykerr added enhancement New feature or request and removed bug Something isn't working labels Jun 20, 2022
@kennykerr
Copy link
Collaborator

Note that #1811 will change the landscape here, but this is also an important scenario to validate. @rylev

Note that the use of IReference<T> here implies the property is optional and can accept a null, logically None, value. Specifically, it should accept Option<T> rather than IntoParam or anything else.

@kennykerr
Copy link
Collaborator

Duplicate of #292

@kennykerr kennykerr marked this as a duplicate of #292 Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants