config: add sandbox client criteria
This commit is contained in:
parent
fd2163d658
commit
9bf79bf23c
20 changed files with 465 additions and 46 deletions
|
|
@ -81,7 +81,12 @@ pub enum ClientCriterionIpc {
|
|||
field: ClientCriterionStringField,
|
||||
regex: bool,
|
||||
},
|
||||
Sandboxed,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum ClientCriterionStringField {}
|
||||
pub enum ClientCriterionStringField {
|
||||
SandboxEngine,
|
||||
SandboxAppId,
|
||||
SandboxInstanceId,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
use {
|
||||
crate::{
|
||||
_private::{
|
||||
ClientCriterionIpc, Config, ConfigEntry, ConfigEntryGen, GenericCriterionIpc,
|
||||
PollableId, VERSION, WireMode, bincode_ops,
|
||||
ClientCriterionIpc, ClientCriterionStringField, Config, ConfigEntry, ConfigEntryGen,
|
||||
GenericCriterionIpc, PollableId, VERSION, WireMode, bincode_ops,
|
||||
ipc::{
|
||||
ClientMessage, InitMessage, Response, ServerFeature, ServerMessage, WorkspaceSource,
|
||||
},
|
||||
|
|
@ -1501,7 +1501,6 @@ impl ConfigClient {
|
|||
criterion: ClientCriterion<'_>,
|
||||
child: bool,
|
||||
) -> (ClientMatcher, bool) {
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! string {
|
||||
($t:expr, $field:ident, $regex:expr) => {
|
||||
ClientCriterionIpc::String {
|
||||
|
|
@ -1530,15 +1529,20 @@ impl ConfigClient {
|
|||
destroy_matcher,
|
||||
)
|
||||
};
|
||||
#[expect(unused_variables)]
|
||||
let criterion = match criterion {
|
||||
ClientCriterion::Matcher(m) => return generic(GenericCriterion::Matcher(m)),
|
||||
ClientCriterion::Not(c) => return generic(GenericCriterion::Not(c)),
|
||||
ClientCriterion::All(c) => return generic(GenericCriterion::All(c)),
|
||||
ClientCriterion::Any(c) => return generic(GenericCriterion::Any(c)),
|
||||
ClientCriterion::Exactly(n, c) => return generic(GenericCriterion::Exactly(n, c)),
|
||||
ClientCriterion::SandboxEngine(t) => string!(t, SandboxEngine, false),
|
||||
ClientCriterion::SandboxEngineRegex(t) => string!(t, SandboxEngine, true),
|
||||
ClientCriterion::SandboxAppId(t) => string!(t, SandboxAppId, false),
|
||||
ClientCriterion::SandboxAppIdRegex(t) => string!(t, SandboxAppId, true),
|
||||
ClientCriterion::SandboxInstanceId(t) => string!(t, SandboxInstanceId, false),
|
||||
ClientCriterion::SandboxInstanceIdRegex(t) => string!(t, SandboxInstanceId, true),
|
||||
ClientCriterion::Sandboxed => ClientCriterionIpc::Sandboxed,
|
||||
};
|
||||
#[expect(unreachable_code)]
|
||||
let res = self.send_with_response(&ClientMessage::CreateClientMatcher { criterion });
|
||||
get_response!(
|
||||
res,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,20 @@ pub enum ClientCriterion<'a> {
|
|||
Any(&'a [ClientCriterion<'a>]),
|
||||
/// Matches if an exact number of the contained criteria match.
|
||||
Exactly(usize, &'a [ClientCriterion<'a>]),
|
||||
/// Matches the engine name of the client's sandbox verbatim.
|
||||
SandboxEngine(&'a str),
|
||||
/// Matches the engine name of the client's sandbox with a regular expression.
|
||||
SandboxEngineRegex(&'a str),
|
||||
/// Matches the app id of the client's sandbox verbatim.
|
||||
SandboxAppId(&'a str),
|
||||
/// Matches the app id of the client's sandbox with a regular expression.
|
||||
SandboxAppIdRegex(&'a str),
|
||||
/// Matches the instance id of the client's sandbox verbatim.
|
||||
SandboxInstanceId(&'a str),
|
||||
/// Matches the instance id of the client's sandbox with a regular expression.
|
||||
SandboxInstanceIdRegex(&'a str),
|
||||
/// Matches if the client is sandboxed.
|
||||
Sandboxed,
|
||||
}
|
||||
|
||||
impl ClientCriterion<'_> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue