Skip to content

Commit

Permalink
Merge pull request #18 from siketyan/renovate/windows-0.x
Browse files Browse the repository at this point in the history
fix(deps): update rust crate windows to 0.51.1
  • Loading branch information
siketyan authored Sep 26, 2023
2 parents 6c992c1 + eac0f10 commit be399de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 73 deletions.
85 changes: 19 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clap = { version = "4.4", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "0.46.0"
version = "0.51.1"
features = [
"Win32_Foundation",
"Win32_Security_Credentials",
Expand Down
12 changes: 6 additions & 6 deletions src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait GhKeyring {
mod windows {
use super::*;
use ::windows::core::PCWSTR;
use ::windows::Win32::Foundation::{GetLastError, ERROR_NOT_FOUND};
use ::windows::Win32::Foundation::ERROR_NOT_FOUND;
use ::windows::Win32::Security::Credentials::{
CredFree, CredReadW, CREDENTIALW, CRED_TYPE_GENERIC,
};
Expand All @@ -34,7 +34,7 @@ mod windows {
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Win32 API error: {0}")]
Win32(u32),
Win32(i32),
}

pub struct Wincred;
Expand All @@ -50,10 +50,10 @@ mod windows {
.as_ptr(),
);

match unsafe { CredReadW(name, CRED_TYPE_GENERIC.0, 0, credential.as_mut_ptr()) }.ok() {
Err(_) => match unsafe { GetLastError() } {
ERROR_NOT_FOUND => Ok(None),
e => Err(Error::Win32(e.0)),
match unsafe { CredReadW(name, CRED_TYPE_GENERIC.0, 0, credential.as_mut_ptr()) } {
Err(e) => match e == ERROR_NOT_FOUND.into() {
true => Ok(None),
_ => Err(Error::Win32(e.code().0)),
},
Ok(_) => {
let credential = unsafe { credential.assume_init() };
Expand Down

0 comments on commit be399de

Please sign in to comment.