-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to override
GetTrustLevel
return value (#2714)
- Loading branch information
Showing
4 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#![allow(non_snake_case)] | ||
|
||
use windows::core::*; | ||
use windows::Foundation::*; | ||
|
||
#[implement(IStringable)] | ||
struct BaseTrust; | ||
|
||
impl IStringable_Impl for BaseTrust { | ||
fn ToString(&self) -> Result<HSTRING> { | ||
Ok("BaseTrust".into()) | ||
} | ||
} | ||
|
||
#[implement(IClosable, TrustLevel = Partial, IStringable)] | ||
struct PartialTrust; | ||
|
||
impl IStringable_Impl for PartialTrust { | ||
fn ToString(&self) -> Result<HSTRING> { | ||
Ok("PartialTrust".into()) | ||
} | ||
} | ||
|
||
impl IClosable_Impl for PartialTrust { | ||
fn Close(&self) -> Result<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[implement(IStringable, TrustLevel = Full)] | ||
struct FullTrust; | ||
|
||
impl IStringable_Impl for FullTrust { | ||
fn ToString(&self) -> Result<HSTRING> { | ||
Ok("FullTrust".into()) | ||
} | ||
} | ||
|
||
#[test] | ||
fn test() -> Result<()> { | ||
let base: IStringable = BaseTrust.into(); | ||
assert_eq!(base.ToString()?, "BaseTrust"); | ||
assert_eq!(base.cast::<IInspectable>()?.GetTrustLevel()?, 0); | ||
|
||
let partial: IStringable = PartialTrust.into(); | ||
assert_eq!(partial.ToString()?, "PartialTrust"); | ||
assert_eq!(partial.cast::<IInspectable>()?.GetTrustLevel()?, 1); | ||
|
||
let full: IStringable = FullTrust.into(); | ||
assert_eq!(full.ToString()?, "FullTrust"); | ||
assert_eq!(full.cast::<IInspectable>()?.GetTrustLevel()?, 2); | ||
|
||
Ok(()) | ||
} |