-
Notifications
You must be signed in to change notification settings - Fork 574
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Suggestion
I am writing a Rust SDK for PowerToys Command Palette, and it has an interface like below:
enum CommandResultKind {
Dismiss, // Reset the palette to the main page and dismiss
GoHome, // Go back to the main page, but keep it open
GoBack, // Go back one level
Hide, // Keep this page open, but hide the palette.
KeepOpen, // Do nothing.
GoToPage, // Go to another page. GoToPageArgs will tell you where.
ShowToast, // Display a transient message to the user
Confirm, // Display a confirmation dialog
};
[uuid("f9d6423b-bd5e-44bb-a204-2f5c77a72396")]
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface ICommandResultArgs{};
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface IGoToPageArgs requires ICommandResultArgs{
String PageId { get; };
NavigationMode NavigationMode { get; };
}
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface IToastArgs requires ICommandResultArgs{
String Message { get; };
ICommandResult Result { get; };
}
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface IConfirmationArgs requires ICommandResultArgs{
String Title { get; };
String Description { get; };
ICommand PrimaryCommand { get; };
Boolean IsPrimaryCommandCritical { get; };
}
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface ICommandResult {
CommandResultKind Kind { get; };
ICommandResultArgs Args { get; };
}
Currently, I write
#[implement(ICommandResult)]
pub struct CommandResult {
}
Then manually copy everything macro generated and change definition to:
// #[implement(ICommandResult)]
pub enum CommandResult {
Dismiss,
GoHome,
GoBack,
Hide,
#[default]
KeepOpen,
GoToPage(ComObject<GoToPageArgs>),
ShowToast(ComObject<ToastArgs>),
Confirm(ComObject<ConfirmationArgs>),
}
It would be helpful if I can use #[implement(ICommandResult)]
directly.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request