castrum 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +2259 -0
- package/Cargo.toml +138 -0
- package/README.md +6 -0
- package/build.rs +5 -0
- package/castrum.linux-x64-gnu.node +0 -0
- package/dist/index.d.ts +1348 -1295
- package/dist/index.js +4307 -3776
- package/docs/API.md +1 -1
- package/docs/ARCHITECTURE.md +3 -2
- package/docs/CASE_STUDY.md +2 -2
- package/docs/ENVIRONMENT.md +16 -0
- package/docs/FFI_BUN_GUIDE.md +89 -6
- package/docs/REPO_MAP.md +2 -2
- package/index.ts +19 -25
- package/package.json +9 -1
- package/rust/crypto/aead.rs +378 -0
- package/rust/crypto/argon2.rs +265 -0
- package/rust/crypto/base64.rs +420 -0
- package/rust/crypto/bcrypt.rs +89 -0
- package/rust/crypto/cookie_sign.rs +169 -0
- package/rust/crypto/csrf.rs +106 -0
- package/rust/crypto/ed25519.rs +215 -0
- package/rust/crypto/hashing.rs +140 -0
- package/rust/crypto/hmac_sha256.rs +88 -0
- package/rust/crypto/jwt/api.rs +286 -0
- package/rust/crypto/jwt/mod.rs +22 -0
- package/rust/crypto/jwt/tests.rs +312 -0
- package/rust/crypto/jwt/token.rs +360 -0
- package/rust/crypto/mod.rs +27 -0
- package/rust/crypto/pbkdf2.rs +96 -0
- package/rust/crypto/random_token.rs +85 -0
- package/rust/crypto/session.rs +222 -0
- package/rust/ffi/crypto.rs +708 -0
- package/rust/ffi/hashing.rs +285 -0
- package/rust/ffi/http.rs +752 -0
- package/rust/ffi/ingress.rs +303 -0
- package/rust/ffi/json.rs +517 -0
- package/rust/ffi/jwt.rs +419 -0
- package/rust/ffi/metrics.rs +373 -0
- package/rust/ffi/mod.rs +68 -0
- package/rust/ffi/payload.rs +275 -0
- package/rust/ffi/probe.rs +60 -0
- package/rust/ffi/rate_limit.rs +77 -0
- package/rust/ffi/route.rs +85 -0
- package/rust/ffi/tests.rs +2333 -0
- package/rust/ffi/util.rs +152 -0
- package/rust/ffi/validators.rs +123 -0
- package/rust/http/accept.rs +606 -0
- package/rust/http/cookie_parser.rs +140 -0
- package/rust/http/etag.rs +289 -0
- package/rust/http/form.rs +132 -0
- package/rust/http/headers.rs +267 -0
- package/rust/http/http_date.rs +286 -0
- package/rust/http/http_parser.rs +252 -0
- package/rust/http/media_type.rs +355 -0
- package/rust/http/method.rs +200 -0
- package/rust/http/mime_lookup.rs +130 -0
- package/rust/http/mod.rs +32 -0
- package/rust/http/multipart.rs +685 -0
- package/rust/http/query_parser.rs +180 -0
- package/rust/http/url_codec.rs +296 -0
- package/rust/http/url_join.rs +324 -0
- package/rust/ingress/api.rs +355 -0
- package/rust/ingress/cors.rs +403 -0
- package/rust/ingress/ingress_constants.rs +209 -0
- package/rust/ingress/ip_trust.rs +312 -0
- package/rust/ingress/mod.rs +48 -0
- package/rust/ingress/native_route.rs +779 -0
- package/rust/ingress/options.rs +176 -0
- package/rust/ingress/output.rs +406 -0
- package/rust/ingress/packed.rs +191 -0
- package/rust/ingress/pipeline.rs +534 -0
- package/rust/ingress/proxy.rs +138 -0
- package/rust/ingress/rate_limit.rs +538 -0
- package/rust/ingress/terminal.rs +114 -0
- package/rust/ingress/tests.rs +566 -0
- package/rust/ingress/time.rs +70 -0
- package/rust/json/fast_schema/capture.rs +336 -0
- package/rust/json/fast_schema/compile.rs +556 -0
- package/rust/json/fast_schema/cursor.rs +368 -0
- package/rust/json/fast_schema/email.rs +282 -0
- package/rust/json/fast_schema/errors.rs +247 -0
- package/rust/json/fast_schema/mod.rs +57 -0
- package/rust/json/fast_schema/tests.rs +1143 -0
- package/rust/json/fast_schema/types.rs +140 -0
- package/rust/json/fast_schema/validate.rs +931 -0
- package/rust/json/json_ops.rs +121 -0
- package/rust/json/json_schema.rs +837 -0
- package/rust/json/json_ser.rs +881 -0
- package/rust/json/mod.rs +19 -0
- package/rust/json/napi_marshal.rs +318 -0
- package/rust/json/patch/api.rs +60 -0
- package/rust/json/patch/engine.rs +153 -0
- package/rust/json/patch/mod.rs +47 -0
- package/rust/json/patch/ops.rs +270 -0
- package/rust/json/patch/pointer.rs +49 -0
- package/rust/json/patch/tests.rs +499 -0
- package/rust/lib.rs +72 -0
- package/rust/metrics/api.rs +148 -0
- package/rust/metrics/mod.rs +21 -0
- package/rust/metrics/registry.rs +961 -0
- package/rust/panic_safety.rs +40 -0
- package/rust/payload/compress.rs +512 -0
- package/rust/payload/mod.rs +13 -0
- package/rust/payload/sse.rs +214 -0
- package/rust/payload/template.rs +253 -0
- package/rust/payload/websocket.rs +69 -0
- package/rust/payload/ws_frames.rs +354 -0
- package/rust/proptest_suite.rs +139 -0
- package/rust/selection.rs +95 -0
- package/rust/src/bin/native-bench.rs +495 -0
- package/rust/test_support.rs +71 -0
- package/rust/util/batch/api.rs +266 -0
- package/rust/util/batch/core.rs +473 -0
- package/rust/util/batch/mod.rs +23 -0
- package/rust/util/batch/tests.rs +445 -0
- package/rust/util/batch_core.rs +184 -0
- package/rust/util/bytes.rs +407 -0
- package/rust/util/mod.rs +34 -0
- package/rust/util/packed.rs +473 -0
- package/rust/util/text.rs +130 -0
- package/rust/util/threadpool.rs +128 -0
- package/rust/util/validation.rs +419 -0
- package/rust-toolchain.toml +17 -0
- package/scripts/postinstall.mjs +199 -0
- package/src/ingress/constants.ts +1 -1
- package/src/ingress/context.ts +2 -2
- package/src/ingress/decode/baked-result.ts +13 -13
- package/src/ingress/decode/fast-result.ts +17 -17
- package/src/ingress/errors.ts +7 -7
- package/src/ingress/headers/baked-templates.ts +1 -1
- package/src/ingress/headers/fast-templates.ts +3 -3
- package/src/ingress/index.ts +1 -1
- package/src/ingress/native-route.ts +9 -5
- package/src/ingress/options.ts +1 -1
- package/src/ingress/packing/gather-raw-headers.ts +1 -1
- package/src/ingress/packing/route-wire.ts +1 -5
- package/src/ingress/response/error-bodies.ts +5 -5
- package/src/ingress/response/terminal.ts +1 -1
- package/src/ingress/routes/echo.ts +4 -4
- package/src/ingress/routes/fallback.ts +2 -2
- package/src/ingress/routes/head.ts +2 -2
- package/src/ingress/routes/native.ts +2 -1
- package/src/ingress/routes/options.ts +1 -1
- package/src/ingress/routes/read.ts +2 -2
- package/src/ingress/server.ts +10 -6
- package/src/ingress/status.ts +7 -7
- package/src/integration/batch.ts +1 -1
- package/src/integration/index.ts +9 -9
- package/src/integration/pipeline.ts +6 -6
- package/src/integration/websocket.ts +2 -2
- package/src/loader/index.ts +1 -5
- package/src/loader/ops.ts +1 -1
- package/src/native/ffi/build/codecs.ts +104 -8
- package/src/native/ffi/build/compress.ts +14 -10
- package/src/native/ffi/build/instances.ts +40 -3
- package/src/native/ffi/build/metrics.ts +224 -0
- package/src/native/ffi/build/parse.ts +59 -23
- package/src/native/ffi/build/util.ts +14 -1
- package/src/native/ffi/build.ts +2 -0
- package/src/native/ffi/selftest.ts +10 -3
- package/src/native/ffi/types.ts +111 -9
- package/src/native/ffi.ts +87 -1
- package/src/native/index.ts +1 -1
- package/src/native/loader.ts +2 -2
- package/src/native/types/instances.ts +34 -0
- package/src/native/types.ts +11 -0
- package/src/runtime/codec.ts +53 -9
- package/src/runtime/types.ts +7 -0
- package/src/rust-ffi/batch/build.ts +16 -9
- package/src/rust-ffi/index.ts +7 -6
- package/src/rust-ffi/options.ts +1 -3
- package/src/rust-ffi/proven.ts +3 -3
- package/src/rust-ffi/scalar/crypto.ts +1 -1
- package/src/rust-ffi/scalar/factories.ts +73 -0
- package/src/rust-ffi/scalar/hashing.ts +1 -1
- package/src/rust-ffi/scalar/http.ts +17 -11
- package/src/rust-ffi/scalar/index.ts +2 -0
- package/src/rust-ffi/scalar/interface.ts +20 -0
- package/src/rust-ffi/scalar/payload.ts +11 -3
- package/src/rust-ffi/scalar/validation.ts +121 -0
- package/src/selection.ts +1 -1
- package/src/shared/bytes.ts +5 -4
- package/src/shared/codec.ts +18 -3
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// rust/util/batch/api.rs — napi boundary for the packed aggregate batch APIs.
|
|
2
|
+
//
|
|
3
|
+
// Thin `#[napi]` wrappers over the routing core in `core.rs`. Grouped into the
|
|
4
|
+
// three JS-facing families: sync packed→packed, aggregate (count/total), and
|
|
5
|
+
// reusable-output (`_into`) variants.
|
|
6
|
+
|
|
7
|
+
use napi::bindgen_prelude::*;
|
|
8
|
+
use napi_derive::napi;
|
|
9
|
+
|
|
10
|
+
use crate::crypto::hashing::fnv1a64_bytes;
|
|
11
|
+
use crate::json::json_ops::json_sum_ids_bytes;
|
|
12
|
+
use crate::util::validation::{
|
|
13
|
+
validate_email_bytes, validate_ipv4_bytes, validate_ipv6_bytes, validate_uuid_bytes,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
use super::core::{
|
|
17
|
+
bytes_map_serial, cookie_parse_batch_bytes, count_batch_data, form_parse_batch_bytes,
|
|
18
|
+
hex_decode_batch_bytes, hex_encode_batch_bytes, hmac_sha256_batch_bytes,
|
|
19
|
+
hmac_sha256_verify_batch_bytes, http_parse_request_batch_bytes, json_sum_batch_bytes,
|
|
20
|
+
json_valid_batch_bytes, query_parse_batch_bytes, run_bitset_batch, run_sum_batch,
|
|
21
|
+
sign_cookie_batch_bytes, sum_ids_batch_data, total_len_batch_data, validate_email_batch_bytes,
|
|
22
|
+
validate_ipv4_batch_bytes, validate_ipv6_batch_bytes, validate_uuid_batch_bytes,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// ── Sync packed batch APIs ──
|
|
26
|
+
|
|
27
|
+
#[napi]
|
|
28
|
+
pub fn json_valid_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
29
|
+
Ok(Buffer::from(json_valid_batch_bytes(input.as_ref())?))
|
|
30
|
+
}
|
|
31
|
+
#[napi]
|
|
32
|
+
pub fn validate_email_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
33
|
+
Ok(Buffer::from(validate_email_batch_bytes(input.as_ref())?))
|
|
34
|
+
}
|
|
35
|
+
#[napi]
|
|
36
|
+
pub fn validate_uuid_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
37
|
+
Ok(Buffer::from(validate_uuid_batch_bytes(input.as_ref())?))
|
|
38
|
+
}
|
|
39
|
+
#[napi]
|
|
40
|
+
pub fn validate_ipv4_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
41
|
+
Ok(Buffer::from(validate_ipv4_batch_bytes(input.as_ref())?))
|
|
42
|
+
}
|
|
43
|
+
#[napi]
|
|
44
|
+
pub fn validate_ipv6_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
45
|
+
Ok(Buffer::from(validate_ipv6_batch_bytes(input.as_ref())?))
|
|
46
|
+
}
|
|
47
|
+
#[napi]
|
|
48
|
+
pub fn json_sum_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
49
|
+
Ok(Buffer::from(json_sum_batch_bytes(input.as_ref())?))
|
|
50
|
+
}
|
|
51
|
+
#[napi]
|
|
52
|
+
pub fn fnv1a64_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
53
|
+
Ok(Buffer::from(run_sum_batch(input.as_ref(), |item| {
|
|
54
|
+
fnv1a64_bytes(item) as i64
|
|
55
|
+
})?))
|
|
56
|
+
}
|
|
57
|
+
#[napi]
|
|
58
|
+
pub fn query_parse_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
59
|
+
Ok(Buffer::from(query_parse_batch_bytes(input.as_ref())?))
|
|
60
|
+
}
|
|
61
|
+
#[napi]
|
|
62
|
+
pub fn cookie_parse_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
63
|
+
Ok(Buffer::from(cookie_parse_batch_bytes(input.as_ref())?))
|
|
64
|
+
}
|
|
65
|
+
#[napi]
|
|
66
|
+
pub fn form_parse_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
67
|
+
Ok(Buffer::from(form_parse_batch_bytes(input.as_ref())?))
|
|
68
|
+
}
|
|
69
|
+
#[napi]
|
|
70
|
+
pub fn sign_cookie_batch_packed(data: Uint8Array, secret: Uint8Array) -> Result<Buffer> {
|
|
71
|
+
Ok(Buffer::from(sign_cookie_batch_bytes(
|
|
72
|
+
data.as_ref(),
|
|
73
|
+
secret.as_ref(),
|
|
74
|
+
)?))
|
|
75
|
+
}
|
|
76
|
+
#[napi]
|
|
77
|
+
pub fn verify_cookie_batch_packed(data: Uint8Array, secret: Uint8Array) -> Result<Buffer> {
|
|
78
|
+
let key = aws_lc_rs::hmac::Key::new(aws_lc_rs::hmac::HMAC_SHA256, secret.as_ref());
|
|
79
|
+
run_bitset_batch(
|
|
80
|
+
data.as_ref(),
|
|
81
|
+
|s| crate::crypto::cookie_sign::verify_cookie_bytes_bool(s, &key),
|
|
82
|
+
4096,
|
|
83
|
+
)
|
|
84
|
+
.map(Buffer::from)
|
|
85
|
+
}
|
|
86
|
+
#[napi]
|
|
87
|
+
pub fn csrf_verify_batch_packed(data: Uint8Array, secret: Uint8Array) -> Result<Buffer> {
|
|
88
|
+
let key = aws_lc_rs::hmac::Key::new(aws_lc_rs::hmac::HMAC_SHA256, secret.as_ref());
|
|
89
|
+
run_bitset_batch(
|
|
90
|
+
data.as_ref(),
|
|
91
|
+
|t| crate::crypto::csrf::csrf_verify_with_key(t, &key),
|
|
92
|
+
4096,
|
|
93
|
+
)
|
|
94
|
+
.map(Buffer::from)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ── HMAC-SHA256 batch (packed) ──
|
|
98
|
+
|
|
99
|
+
#[napi]
|
|
100
|
+
pub fn hmac_sha256_batch_packed(input: Uint8Array, key: Uint8Array) -> Result<Buffer> {
|
|
101
|
+
let key = aws_lc_rs::hmac::Key::new(aws_lc_rs::hmac::HMAC_SHA256, key.as_ref());
|
|
102
|
+
Ok(Buffer::from(hmac_sha256_batch_bytes(input.as_ref(), &key)?))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#[napi]
|
|
106
|
+
pub fn hmac_sha256_verify_batch_packed(
|
|
107
|
+
input: Uint8Array,
|
|
108
|
+
sigs: Uint8Array,
|
|
109
|
+
key: Uint8Array,
|
|
110
|
+
) -> Result<Buffer> {
|
|
111
|
+
let key = aws_lc_rs::hmac::Key::new(aws_lc_rs::hmac::HMAC_SHA256, key.as_ref());
|
|
112
|
+
Ok(Buffer::from(hmac_sha256_verify_batch_bytes(
|
|
113
|
+
input.as_ref(),
|
|
114
|
+
sigs.as_ref(),
|
|
115
|
+
&key,
|
|
116
|
+
)?))
|
|
117
|
+
}
|
|
118
|
+
#[napi]
|
|
119
|
+
pub fn http_parse_request_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
120
|
+
Ok(Buffer::from(http_parse_request_batch_bytes(
|
|
121
|
+
input.as_ref(),
|
|
122
|
+
)?))
|
|
123
|
+
}
|
|
124
|
+
#[napi]
|
|
125
|
+
pub fn hex_encode_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
126
|
+
Ok(Buffer::from(hex_encode_batch_bytes(input.as_ref())?))
|
|
127
|
+
}
|
|
128
|
+
#[napi]
|
|
129
|
+
pub fn hex_decode_batch_packed(input: Uint8Array) -> Result<Buffer> {
|
|
130
|
+
Ok(Buffer::from(hex_decode_batch_bytes(input.as_ref())?))
|
|
131
|
+
}
|
|
132
|
+
#[napi]
|
|
133
|
+
pub fn base64_encode_batch_packed(
|
|
134
|
+
input: Uint8Array,
|
|
135
|
+
url_safe: Option<bool>,
|
|
136
|
+
padding: Option<bool>,
|
|
137
|
+
) -> Result<Buffer> {
|
|
138
|
+
let us = url_safe.unwrap_or(false);
|
|
139
|
+
let pad = padding.unwrap_or(true);
|
|
140
|
+
let out = bytes_map_serial(input.as_ref(), move |v| {
|
|
141
|
+
crate::crypto::base64::base64_encode_bytes(v, us, pad)
|
|
142
|
+
})?;
|
|
143
|
+
Ok(Buffer::from(out))
|
|
144
|
+
}
|
|
145
|
+
#[napi]
|
|
146
|
+
pub fn base64_decode_batch_packed(
|
|
147
|
+
input: Uint8Array,
|
|
148
|
+
url_safe: Option<bool>,
|
|
149
|
+
padding: Option<bool>,
|
|
150
|
+
) -> Result<Buffer> {
|
|
151
|
+
let us = url_safe.unwrap_or(false);
|
|
152
|
+
let pad = padding.unwrap_or(true);
|
|
153
|
+
let out = bytes_map_serial(input.as_ref(), move |v| {
|
|
154
|
+
crate::crypto::base64::base64_decode_bytes(v, us, pad)
|
|
155
|
+
.map_err(|e| Error::from_reason(e.to_string()))
|
|
156
|
+
.unwrap_or_default()
|
|
157
|
+
})?;
|
|
158
|
+
Ok(Buffer::from(out))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ── Aggregate sync packed batch APIs ──
|
|
162
|
+
|
|
163
|
+
#[napi]
|
|
164
|
+
pub fn json_valid_batch_count_packed(input: Uint8Array) -> Result<u32> {
|
|
165
|
+
count_batch_data(input.as_ref(), crate::json::json_ops::json_valid_bytes, 512)
|
|
166
|
+
}
|
|
167
|
+
#[napi]
|
|
168
|
+
pub fn validate_email_batch_count_packed(input: Uint8Array) -> Result<u32> {
|
|
169
|
+
count_batch_data(input.as_ref(), validate_email_bytes, 4096)
|
|
170
|
+
}
|
|
171
|
+
#[napi]
|
|
172
|
+
pub fn validate_uuid_batch_count_packed(input: Uint8Array) -> Result<u32> {
|
|
173
|
+
count_batch_data(input.as_ref(), validate_uuid_bytes, 4096)
|
|
174
|
+
}
|
|
175
|
+
#[napi]
|
|
176
|
+
pub fn validate_ipv4_batch_count_packed(input: Uint8Array) -> Result<u32> {
|
|
177
|
+
count_batch_data(input.as_ref(), validate_ipv4_bytes, 4096)
|
|
178
|
+
}
|
|
179
|
+
#[napi]
|
|
180
|
+
pub fn validate_ipv6_batch_count_packed(input: Uint8Array) -> Result<u32> {
|
|
181
|
+
count_batch_data(input.as_ref(), validate_ipv6_bytes, 4096)
|
|
182
|
+
}
|
|
183
|
+
#[napi]
|
|
184
|
+
pub fn json_sum_batch_total_packed(input: Uint8Array) -> Result<i64> {
|
|
185
|
+
sum_ids_batch_data(input.as_ref(), 512)
|
|
186
|
+
}
|
|
187
|
+
#[napi]
|
|
188
|
+
pub fn query_parse_batch_total_len_packed(input: Uint8Array) -> Result<u32> {
|
|
189
|
+
total_len_batch_data(
|
|
190
|
+
input.as_ref(),
|
|
191
|
+
crate::http::query_parser::query_parse_packed_vec,
|
|
192
|
+
256,
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
#[napi]
|
|
196
|
+
pub fn cookie_parse_batch_total_len_packed(input: Uint8Array) -> Result<u32> {
|
|
197
|
+
total_len_batch_data(
|
|
198
|
+
input.as_ref(),
|
|
199
|
+
crate::http::cookie_parser::cookie_parse_packed_vec,
|
|
200
|
+
256,
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
#[napi]
|
|
204
|
+
pub fn http_parse_request_batch_total_len_packed(input: Uint8Array) -> Result<u32> {
|
|
205
|
+
total_len_batch_data(
|
|
206
|
+
input.as_ref(),
|
|
207
|
+
crate::http::http_parser::http_parse_request_packed_vec,
|
|
208
|
+
256,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ── Reusable-output (`_into`) packed batch variants ──
|
|
213
|
+
// Write the packed result into a caller-provided buffer and return bytes
|
|
214
|
+
// written. Wire format is byte-identical to the allocating variants; the JS
|
|
215
|
+
// loader uses these with a pooled output buffer to avoid per-call allocation.
|
|
216
|
+
// `run_packed_into` guards against input/output aliasing (copies input when
|
|
217
|
+
// they overlap) and every write is capacity-checked.
|
|
218
|
+
|
|
219
|
+
#[napi]
|
|
220
|
+
pub fn json_valid_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
221
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
222
|
+
crate::util::write_bitset_batch_into(data, out, crate::json::json_ops::json_valid_bytes)
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
#[napi]
|
|
227
|
+
pub fn validate_email_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
228
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
229
|
+
crate::util::write_bitset_batch_into(data, out, validate_email_bytes)
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#[napi]
|
|
234
|
+
pub fn validate_uuid_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
235
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
236
|
+
crate::util::write_bitset_batch_into(data, out, validate_uuid_bytes)
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#[napi]
|
|
241
|
+
pub fn validate_ipv4_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
242
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
243
|
+
crate::util::write_bitset_batch_into(data, out, validate_ipv4_bytes)
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#[napi]
|
|
248
|
+
pub fn validate_ipv6_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
249
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
250
|
+
crate::util::write_bitset_batch_into(data, out, validate_ipv6_bytes)
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
#[napi]
|
|
255
|
+
pub fn json_sum_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
256
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
257
|
+
crate::util::write_sum_batch_into(data, out, |item| json_sum_ids_bytes(item).unwrap_or(0))
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#[napi]
|
|
262
|
+
pub fn fnv1a64_batch_packed_into(input: Uint8Array, mut output: Uint8Array) -> Result<u32> {
|
|
263
|
+
crate::util::run_packed_into(&input, &mut output, |data, out| {
|
|
264
|
+
crate::util::write_sum_batch_into(data, out, |item| fnv1a64_bytes(item) as i64)
|
|
265
|
+
})
|
|
266
|
+
}
|