Skip to content
Draft
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
43 changes: 24 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/capabilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ http = "1"
bytes = "1.4"
futures-core = "0.3"
anyhow = "1"
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3081603d3c74f209be4e3be951f78a1a7469397f" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3cdb794e501bc37e52090b032f0b4be116f9a26f" }

[dev-dependencies]
wasm-bindgen-test = "0.3"
4 changes: 4 additions & 0 deletions crates/capabilities/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl HttpClientCapability for WasmHttpClient {
Self
}

fn new_without_connection_pooling() -> Self {
Self
}

#[allow(clippy::manual_async_fn)]
fn request(
&self,
Expand Down
39 changes: 39 additions & 0 deletions crates/capabilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ use std::time::Duration;
use libdd_capabilities::env::{EnvCapability, EnvError};
use libdd_capabilities::file::{FileCapability, FileError, FileMetadata};
use libdd_capabilities::http::HttpError;
use libdd_capabilities::regex::{Captures, Match, RegexCapability, RegexError};
use libdd_capabilities::{HttpClientCapability, LogWriterCapability, MaybeSend, SleepCapability};

pub mod env;
pub mod file;
pub mod http;
pub mod regex;
pub mod sleep;

pub use env::WasmEnvCapability;
pub use file::WasmFileCapability;
pub use http::WasmHttpClient;
pub use regex::{WasmRegexCapability, WasmRegexHandle};
pub use sleep::WasmSleepCapability;

/// Bundle of wasm platform capabilities for libdatadog's `TraceExporter`.
Expand Down Expand Up @@ -65,6 +68,10 @@ impl HttpClientCapability for WasmCapabilities {
Self::new()
}

fn new_without_connection_pooling() -> Self {
Self::new()
}

fn request(
&self,
req: ::http::Request<::bytes::Bytes>,
Expand Down Expand Up @@ -135,3 +142,35 @@ impl EnvCapability for WasmCapabilities {
self.env.get(name)
}
}

impl RegexCapability for WasmCapabilities {
type Handle = <WasmRegexCapability as RegexCapability>::Handle;

fn compile(pattern: &str) -> Result<Self::Handle, RegexError> {
WasmRegexCapability::compile(pattern)
}

fn is_match(handle: &Self::Handle, haystack: &str) -> bool {
WasmRegexCapability::is_match(handle, haystack)
}

fn find(handle: &Self::Handle, haystack: &str) -> Option<Match> {
WasmRegexCapability::find(handle, haystack)
}

fn find_all(handle: &Self::Handle, haystack: &str) -> Vec<Match> {
WasmRegexCapability::find_all(handle, haystack)
}

fn captures(handle: &Self::Handle, haystack: &str) -> Option<Captures> {
WasmRegexCapability::captures(handle, haystack)
}

fn captures_all(handle: &Self::Handle, haystack: &str) -> Vec<Captures> {
WasmRegexCapability::captures_all(handle, haystack)
}

fn pattern(handle: &Self::Handle) -> &str {
WasmRegexCapability::pattern(handle)
}
}
Loading
Loading