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

API draft for the rewrite #308

Draft
wants to merge 23 commits into
base: rewrite
Choose a base branch
from

Conversation

oskardotglobal
Copy link
Member

This PR is a draft for how the API of the rewrite could look like.
There are no implementations yet, but once the API is stable the implementations for features can gradually be put in place.

The main difference between the design of legacy WinApps is that the config is the single source of truth for installed apps and will later also contain paths to the icons for the installed apps, meaning we can get rid of the "pre-configured" apps currently found in the apps folder. A sample config would look like this:

[auth]
username = "Docker"
password = ""
domain = ""

[container]
enable = true
enable_podman = false
container_name = "WinApps"

[libvirt]
enable = false
vm_name = "RDPWindows"

[manual]
enable = false
host = "127.0.0.1"

[[installed_apps]]
id = "explorer"
name = "Explorer"
win_exec = "explorer.exe"

# [[installed_apps]]
# id = ...

This also merges and therefore supersedes #195.

winapps/src/backend/docker.rs Fixed Show fixed Hide fixed
winapps/src/backend/docker.rs Fixed Show fixed Hide fixed
winapps/src/remote_client/freerdp.rs Fixed Show fixed Hide fixed
winapps/src/remote_client/freerdp.rs Fixed Show fixed Hide fixed
winapps/src/lib.rs Fixed Show fixed Hide fixed
winapps/src/lib.rs Fixed Show fixed Hide fixed
@oskardotglobal
Copy link
Member Author

I've been working on this and there are still some implementations and features missing, but as far as the API goes I think it's pretty good.

This is currently still missing the entire libvirt implementation as well as the MULTIMON and SCALE config settings and the app detection, which doesn't even have a proper Api yet.

However, the connection check using a TcpStream should already be more stable than the simple check using Netcat, so I think there's a lot of value to be had here once this is more feature-complete.

}
match sub_matches.get_one::<String>("NAME") {
None => bail!("App is required and should never be None here"),
Some(app) => client.run_executable(app.to_owned()),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably make this nicer without to_owned

kill_vm(config);
}
match sub_matches.get_one::<String>("NAME") {
None => bail!("App is required and should never be None here"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably panic

See log above for more detail."
.into(),
)
pub macro ensure {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a docstring

($expr:expr, $($fmt:tt)*) => {{
$crate::into_error!($expr, format!($($fmt)*)).unwrap_or_else(|e| e.panic())
}};
pub macro bail {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs doc


use crate::{bail, Config, Error, IntoResult, Result};

static CONFIG: OnceLock<Config> = OnceLock::new();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This static can probably be inlined into load

@LDprg
Copy link
Member

LDprg commented Jan 15, 2025

This seems great (just a quick look, no proper review). I didn't checked the repo in a while (as written before I sadly lack time to work on winapps at the moment). Didn't expect this to be that far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants