noticed inconsistency of generated newtype, in module Win32::Networking::Winsock
: sa_family_t
vs socklen_t
#2627
Labels
enhancement
New feature or request
Suggestion
I was writing some code using
Winsock
, then I noticed the typesa_family_t
is a struct with a single named fieldValue
, while the typesocklen_t
is a tuple struct, which are added to the metadata at the same time:microsoft/win32metadata#1041
also, there're other inconsistency such as
sa_family_t
is annotated with#[repr(C)]
whilesocklen_t
is#[repr(transparent)]
,sa_family_t
contains a doc string about the feature flags butsocklen_t
doesn't;socklen_t
has a#[derive(...)]
attribute butsa_family_t
doesn't. here's the generated rust code in thewindows
crate:windows-rs/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs
Lines 16828 to 16832 in 891c469
windows-rs/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs
Lines 16901 to 16903 in 891c469
side note
the `sa_family_t` probably should not be added, since there's `ADDRESS_FAMILY` in winsock2 already:windows-rs/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs
Lines 4959 to 4962 in 891c469
so why is this discrepancy? does the code generator not have defined rule in this case, or is it a corner case? does this need to be fixed?
btw, is there a recommended way to convert a
windows-sys
type alias to the correspondingwindows
crate newtype? should Itransmute()
directly, or can I assume the newtype wrapper would always be a tuple struct (and thesa_family_t
is indeed an error in code generator)? or maybe we can add a new generic api similar tocore::from_abi()
?I like the fact that libraries are using
windows-sys
in their public api, and I also like to use thewindows
crate for the convenience and safety features when writing non public facing code, and often feel the need to bridge the two crate together, however, I can't find in the documentation what's the "proper" way to do the convertion.I wonder is this a uncommon usage, or is there a well established solution and I am just missing the obiouvs? I have read #1393 and some other related issues, but I don't think they are relevant about mixing both
windows-sys
andwindows
crates.The text was updated successfully, but these errors were encountered: