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

chore(wasix): make Capabilities hashable #5291

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/wasix/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::Duration;
use crate::http::HttpClientCapabilityV1;

/// Defines capabilities for a Wasi environment.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Capabilities {
pub insecure_allow_all: bool,
pub http_client: HttpClientCapabilityV1,
Expand Down Expand Up @@ -40,7 +40,7 @@ impl Default for Capabilities {
}

/// Defines threading related permissions.
#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub struct CapabilityThreadingV1 {
/// Maximum number of threads that can be spawned.
///
Expand Down
10 changes: 5 additions & 5 deletions lib/wasix/src/http/client.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
use std::{collections::HashSet, ops::Deref, sync::Arc};
use std::{collections::BTreeSet, ops::Deref, sync::Arc};

use futures::future::BoxFuture;
use http::{HeaderMap, Method, StatusCode};
use url::Url;

/// Defines http client permissions.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct HttpClientCapabilityV1 {
pub allow_all: bool,
pub allowed_hosts: HashSet<String>,
pub allowed_hosts: BTreeSet<String>,
}

impl HttpClientCapabilityV1 {
pub fn new() -> Self {
Self {
allow_all: false,
allowed_hosts: HashSet::new(),
allowed_hosts: Default::default(),
}
}

pub fn new_allow_all() -> Self {
Self {
allow_all: true,
allowed_hosts: HashSet::new(),
allowed_hosts: Default::default(),
}
}

Expand Down
Loading