From 01655539ca91f46cabe51346ac9747108c067d2c Mon Sep 17 00:00:00 2001 From: fffonion Date: Mon, 16 Nov 2026 03:15:17 +0800 Subject: [PATCH 1/2] chore(core): pin RustScript and align RSS option syntax --- Cargo.lock | 6 +- Cargo.toml | 6 +- README.md | 2 +- docs/api/shared-dict.md | 4 +- docs/api/standard-async.md | 8 +- docs/design/ngx-scheduler.md | 6 +- examples/async-pipeline.rss | 22 +- examples/key-auth.rss | 4 +- examples/rate-limit.rss | 8 +- src/request_state.rs | 2 +- src/vm_pool.rs | 2 +- tests/access_config.rs | 4 +- tests/access_nginx.rs | 2 +- tests/core_pin.rs | 2 +- tests/host_catalog.rs | 18 +- tests/ngx_request_body.rs | 2 +- tests/shared_dict_nginx.rs | 460 ++++++++++++++++---------------- tests/test_release_packaging.py | 2 +- tests/timer_nginx.rs | 32 +-- 19 files changed, 296 insertions(+), 296 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ff2f31..55df038 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,7 +746,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pd-host-function" version = "0.1.0" -source = "git+https://github.com/rustscript-lang/rustscript?rev=fc8b0c8179640a8ffe460a64b3690e35c2f7eb73#fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" +source = "git+https://github.com/rustscript-lang/rustscript?rev=2f433edab3f1907e8cb060e901357d7e2af016ce#2f433edab3f1907e8cb060e901357d7e2af016ce" dependencies = [ "pd-host-schema", "proc-macro2", @@ -757,7 +757,7 @@ dependencies = [ [[package]] name = "pd-host-schema" version = "0.1.0" -source = "git+https://github.com/rustscript-lang/rustscript?rev=fc8b0c8179640a8ffe460a64b3690e35c2f7eb73#fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" +source = "git+https://github.com/rustscript-lang/rustscript?rev=2f433edab3f1907e8cb060e901357d7e2af016ce#2f433edab3f1907e8cb060e901357d7e2af016ce" dependencies = [ "proc-macro2", "syn 2.0.119", @@ -766,7 +766,7 @@ dependencies = [ [[package]] name = "pd-vm" version = "0.1.0" -source = "git+https://github.com/rustscript-lang/rustscript?rev=fc8b0c8179640a8ffe460a64b3690e35c2f7eb73#fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" +source = "git+https://github.com/rustscript-lang/rustscript?rev=2f433edab3f1907e8cb060e901357d7e2af016ce#2f433edab3f1907e8cb060e901357d7e2af016ce" dependencies = [ "base64", "futures-channel", diff --git a/Cargo.toml b/Cargo.toml index 42f93ec..7d085fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ ngx-rust-rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187" nginx-core-version = "1.31.4" nginx-core-tarball-sha256 = "e6f20b644a17a643f059ae6467a1971fe2811587d025e071068753a1f1e3b3c3" rustscript-git = "https://github.com/rustscript-lang/rustscript" -rustscript-rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" +rustscript-rev = "2f433edab3f1907e8cb060e901357d7e2af016ce" [lib] crate-type = ["cdylib", "rlib"] @@ -27,7 +27,7 @@ sha1 = { version = "0.10", default-features = false } sha2 = { version = "0.10", default-features = false } nginx-sys = { git = "https://github.com/nginx/ngx-rust", rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187" } ngx = { git = "https://github.com/nginx/ngx-rust", rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187", default-features = false, features = ["std"] } -pd-host-function = { git = "https://github.com/rustscript-lang/rustscript", rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" } +pd-host-function = { git = "https://github.com/rustscript-lang/rustscript", rev = "2f433edab3f1907e8cb060e901357d7e2af016ce" } tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "time", "net", "sync", "io-util"] } rustls = { version = "0.23", default-features = false, features = ["std", "tls12", "ring"] } tokio-rustls = { version = "0.26", default-features = false, features = ["ring"] } @@ -36,7 +36,7 @@ rustls-pemfile = { version = "2", default-features = false, features = ["std"] } rustls-native-certs = "0.8" webpki-roots = "0.26" zeroize = { version = "1", default-features = false, features = ["alloc"] } -vm = { package = "pd-vm", git = "https://github.com/rustscript-lang/rustscript", rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73", default-features = false, features = ["runtime", "async", "http-client", "sqlite"] } +vm = { package = "pd-vm", git = "https://github.com/rustscript-lang/rustscript", rev = "2f433edab3f1907e8cb060e901357d7e2af016ce", default-features = false, features = ["runtime", "async", "http-client", "sqlite"] } [features] default = ["export-modules"] diff --git a/README.md b/README.md index b55a459..d18e7dc 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ phase stays synchronous and fail-closed. | --- | --- | | [ngx-rust](https://github.com/nginx/ngx-rust) | `cda9d8372ccd2e139ef2b03e5806e019e7796187` (`ngx` / `nginx-sys` 0.5.0) | | NGINX | Official NGINX 1.31.4 (`nginx_version` 1031004), tarball SHA-256 `e6f20b644a17a643f059ae6467a1971fe2811587d025e071068753a1f1e3b3c3` | -| RustScript / `pd-vm` | [`https://github.com/rustscript-lang/rustscript`](https://github.com/rustscript-lang/rustscript) at `fc8b0c8179640a8ffe460a64b3690e35c2f7eb73` (Cargo git dependency `package = "pd-vm"` on that immutable rev; no sibling path) | +| RustScript / `pd-vm` | [`https://github.com/rustscript-lang/rustscript`](https://github.com/rustscript-lang/rustscript) at `2f433edab3f1907e8cb060e901357d7e2af016ce` (Cargo git dependency `package = "pd-vm"` on that immutable rev; no sibling path) | | Rust toolchain | 1.85.0 or later (ngx-rust MSRV). Verified with rustc 1.94.1 | Required build tools on Linux: diff --git a/docs/api/shared-dict.md b/docs/api/shared-dict.md index 08bb9e1..8ba7b0e 100644 --- a/docs/api/shared-dict.md +++ b/docs/api/shared-dict.md @@ -75,8 +75,8 @@ if added.ok { } let stored: SharedGetResult = ngx::shared::get(dict, key); let text = match stored.value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" }; ``` Keys are at most 65535 bytes; values at most 65536 bytes. diff --git a/docs/api/standard-async.md b/docs/api/standard-async.md index e59e0ae..8c63567 100644 --- a/docs/api/standard-async.md +++ b/docs/api/standard-async.md @@ -279,8 +279,8 @@ Example: use sqlite; let db = sqlite::open({ - path: Option::Some("pipeline.db"), - mode: Option::Some("read_write_create") + path: Some("pipeline.db"), + mode: Some("read_write_create") }); let created: SqliteExecuteResult = sqlite::execute( db, @@ -290,13 +290,13 @@ let created: SqliteExecuteResult = sqlite::execute( let inserted: SqliteExecuteResult = sqlite::execute( db, "INSERT INTO events(body) VALUES (?1)", - [{ kind: "text", text_value: Option::Some("payload") }] + [{ kind: "text", text_value: Some("payload") }] ); let rows: SqliteQueryResult = sqlite::query( db, "SELECT body FROM events ORDER BY rowid DESC LIMIT 10", [], - { max_rows: Option::Some(10) } + { max_rows: Some(10) } ); sqlite::close(db); ``` diff --git a/docs/design/ngx-scheduler.md b/docs/design/ngx-scheduler.md index e4ecf62..397f5c3 100644 --- a/docs/design/ngx-scheduler.md +++ b/docs/design/ngx-scheduler.md @@ -27,8 +27,8 @@ Pinned `pd-vm` evidence in this file is taken from: | Pin | Value | | --- | --- | | Crate metadata | `Cargo.toml` `rustscript-rev` / `vm` git `rev` | -| `Cargo.lock` | `pd-vm` `source = "git+https://github.com/rustscript-lang/rustscript?rev=fc8b0c8179640a8ffe460a64b3690e35c2f7eb73#fc8b0c8179640a8ffe460a64b3690e35c2f7eb73"` | -| Local Cargo git checkout | `$CARGO_HOME/git/checkouts/rustscript-ab116a0775a56744/87d8c5d` | +| `Cargo.lock` | `pd-vm` `source = "git+https://github.com/rustscript-lang/rustscript?rev=2f433edab3f1907e8cb060e901357d7e2af016ce#2f433edab3f1907e8cb060e901357d7e2af016ce"` | +| Local Cargo git checkout | `$CARGO_HOME/git/checkouts/rustscript-ab116a0775a56744/2f433ed` | Public versus crate-private is taken from that checkout's `src/lib.rs` re-exports and item visibility. Do not treat crate-private helpers as @@ -123,7 +123,7 @@ Root execution is `Vm::run` / `Vm::resume`. The module does not use `ScriptCallback`, `Store`, `Invocation`, or `Vm::invoke_callable` for production request handling. -## Evidence matrix (pinned `pd-vm` fc8b0c8179640a8ffe460a64b3690e35c2f7eb73) +## Evidence matrix (pinned `pd-vm` 2f433edab3f1907e8cb060e901357d7e2af016ce) Legend: **P** = public (`src/lib.rs` re-export or `pub` item on a public type). **C** = crate-private / `pub(super)` / `pub(crate)`. diff --git a/examples/async-pipeline.rss b/examples/async-pipeline.rss index 2b824df..d2dde18 100644 --- a/examples/async-pipeline.rss +++ b/examples/async-pipeline.rss @@ -6,12 +6,12 @@ use json; use bytes as builtin_bytes; let url_file: string = match ngx::var::get("rss_pipeline_url_file") { - Option::Some(value) => value, - Option::None => "" + Some(value) => value, + None => "" }; let database_file: string = match ngx::var::get("rss_pipeline_database") { - Option::Some(value) => value, - Option::None => "" + Some(value) => value, + None => "" }; fn read_url(path: string) -> Result { @@ -44,20 +44,20 @@ let upstream_json = { }; let database = sqlite::open({ - path: Option::Some(database_file), - mode: Option::Some("read_write_create") + path: Some(database_file), + mode: Some("read_write_create") }); let database_result: SqliteQueryResult = sqlite::query( database, "SELECT 'sqlite-ok' AS source, 42 AS value", [], - {max_rows: Option::Some(8), max_result_bytes: Option::Some(65536)} + {max_rows: Some(8), max_result_bytes: Some(65536)} ); let database_truncated: bool = database_result.truncated; let database_column: string = database_result.columns[0]; let database_first_cell: string = match database_result.rows[0].cells[0].text_value { - Option::Some(text) => text, - Option::None => "" + Some(text) => text, + None => "" }; sqlite::close(database); @@ -70,8 +70,8 @@ let shared: SharedStoreResult = ngx::shared::set( () ); let shared_error = match shared.error { - Option::Some(message) => message, - Option::None => "" + Some(message) => message, + None => "" }; ngx::status::set(200); diff --git a/examples/key-auth.rss b/examples/key-auth.rss index 2199d41..33d93d9 100644 --- a/examples/key-auth.rss +++ b/examples/key-auth.rss @@ -20,8 +20,8 @@ if pepper == "" || expected == "" { let raw = ngx::var::get("http_x_api_key"); let missing = match raw.copy() { - Option::Some(token) => false, - Option::None => true + Some(token) => false, + None => true }; if missing { ngx::header::set("WWW-Authenticate", "ApiKey realm=\"api\""); diff --git a/examples/rate-limit.rss b/examples/rate-limit.rss index 0b985ca..7e61658 100644 --- a/examples/rate-limit.rss +++ b/examples/rate-limit.rss @@ -19,16 +19,16 @@ if added.ok { } } else { let added_error = match added.error { - Option::Some(message) => message, - Option::None => "" + Some(message) => message, + None => "" }; if added_error != "exists" { ngx::exit(ngx::http::status_service_unavailable()); } let counted: SharedIncrResult = ngx::shared::incr(dict, key, 1, (), ()); let counted_error = match counted.error { - Option::Some(message) => message, - Option::None => "" + Some(message) => message, + None => "" }; if counted_error != "" { ngx::exit(ngx::http::status_service_unavailable()); diff --git a/src/request_state.rs b/src/request_state.rs index 102ddab..df52d5a 100644 --- a/src/request_state.rs +++ b/src/request_state.rs @@ -1579,7 +1579,7 @@ ngx::ctx::set("k", "1"); #[test] fn default_standard_host_policy_denies_sqlite() { assert_default_policy_denies( - "use sqlite;\nlet db = sqlite::open({path: Option::Some(\"state.db\"), mode: Option::Some(\"read_write_create\")});\nsqlite::close(db);\n", + "use sqlite;\nlet db = sqlite::open({path: Some(\"state.db\"), mode: Some(\"read_write_create\")});\nsqlite::close(db);\n", "database root is not configured", ); } diff --git a/src/vm_pool.rs b/src/vm_pool.rs index dad2935..e174142 100644 --- a/src/vm_pool.rs +++ b/src/vm_pool.rs @@ -1,6 +1,6 @@ //! Worker-thread-local synchronous VM pool. //! -//! pd-vm at `fc8b0c8179640a8ffe460a64b3690e35c2f7eb73` stores `Arc` +//! pd-vm at `2f433edab3f1907e8cb060e901357d7e2af016ce` stores `Arc` //! internally and exposes: //! //! - [`Vm::new_shared`] — shared-program constructor (this pin has no diff --git a/tests/access_config.rs b/tests/access_config.rs index d20cb69..3a5a710 100644 --- a/tests/access_config.rs +++ b/tests/access_config.rs @@ -269,7 +269,7 @@ http::client::sse(request, on_event); ), ( "sqlite", - "use sqlite;\nlet db = sqlite::open({path: Option::Some(\":memory:\"), mode: Option::Some(\"memory\")});\nsqlite::close(db);\n", + "use sqlite;\nlet db = sqlite::open({path: Some(\":memory:\"), mode: Some(\"memory\")});\nsqlite::close(db);\n", ), ]; for (label, source) in retained_or_async_cases { @@ -403,7 +403,7 @@ fn compiled_slot_caches_request_routing_and_sqlite_usage() { let sqlite = compile_rss_source( r#" use sqlite; - let db = sqlite::open({path: Option::Some(":memory:"), mode: Option::Some("memory")}); + let db = sqlite::open({path: Some(":memory:"), mode: Some("memory")}); sqlite::close(db); "#, ) diff --git a/tests/access_nginx.rs b/tests/access_nginx.rs index 53903b4..3329b23 100644 --- a/tests/access_nginx.rs +++ b/tests/access_nginx.rs @@ -930,7 +930,7 @@ fn nginx_denies_in_memory_sqlite_without_sqlite_root() { &script, r#" use sqlite; -let db = sqlite::open({path: Option::Some(":memory:"), mode: Option::Some("memory")}); +let db = sqlite::open({path: Some(":memory:"), mode: Some("memory")}); sqlite::close(db); "#, ) diff --git a/tests/core_pin.rs b/tests/core_pin.rs index c1570a3..f64cc72 100644 --- a/tests/core_pin.rs +++ b/tests/core_pin.rs @@ -3,7 +3,7 @@ use std::fs; use std::path::PathBuf; -const FROZEN_REV: &str = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73"; +const FROZEN_REV: &str = "2f433edab3f1907e8cb060e901357d7e2af016ce"; const STALE_PINS: &[&str] = &["f5f71eb", "f5f71ebc2f38e276c35f2aebaf63f4e2780efe99"]; fn repo_root() -> PathBuf { diff --git a/tests/host_catalog.rs b/tests/host_catalog.rs index 0ea12d3..111c332 100644 --- a/tests/host_catalog.rs +++ b/tests/host_catalog.rs @@ -242,7 +242,7 @@ fn standard_async_imports_compile_and_require_request_owned_execution() { }; let mut request = http::request::new("GET", url); http::client::request(request); - let db = sqlite::open({ path: Option::Some("state.db"), mode: Option::Some("read_write_create") }); + let db = sqlite::open({ path: Some("state.db"), mode: Some("read_write_create") }); sqlite::query(db, "SELECT value FROM events", [], {}); sqlite::close(db); "#, @@ -310,12 +310,12 @@ fn documented_standard_async_interfaces_compile() { fn sqlite_round_trip() -> int { let db = sqlite::open({ - path: Option::Some("state.db"), - mode: Option::Some("read_write_create"), - limits: Option::Some({}) + path: Some("state.db"), + mode: Some("read_write_create"), + limits: Some({}) }); let executed: SqliteExecuteResult = sqlite::execute(db, "CREATE TABLE t (v TEXT)", []); - let queried: SqliteQueryResult = sqlite::query(db, "SELECT v FROM t", [], { max_rows: Option::Some(10) }); + let queried: SqliteQueryResult = sqlite::query(db, "SELECT v FROM t", [], { max_rows: Some(10) }); let transaction_results = sqlite::transaction(db, []); sqlite::close(db); transaction_results; @@ -393,12 +393,12 @@ fn shared_fixed_results_compile_as_explicit_struct_types() { let got: SharedGetResult = ngx::shared::get(dict, "key"); let shared_value = got.value.copy(); let kind = match shared_value { - Option::Some(entry) => entry.kind, - Option::None => "" + Some(entry) => entry.kind, + None => "" }; let text = match shared_value.copy() { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" }; kind; text; diff --git a/tests/ngx_request_body.rs b/tests/ngx_request_body.rs index 456ad74..0ed0486 100644 --- a/tests/ngx_request_body.rs +++ b/tests/ngx_request_body.rs @@ -741,7 +741,7 @@ if file == "" { r#" use ngx; fn arg_pair(entries: [ArgEntry], i: int) -> string { - entries[i]?.name.unwrap_or("") + "=" + entries[i]?.value.unwrap_or(Option::None).unwrap_or("") + entries[i]?.name.unwrap_or("") + "=" + entries[i]?.value.unwrap_or(None).unwrap_or("") } ngx::req::read_body(); let parsed: RequestArgsResult = ngx::req::get_post_args(()); diff --git a/tests/shared_dict_nginx.rs b/tests/shared_dict_nginx.rs index 3071c9f..570af00 100644 --- a/tests/shared_dict_nginx.rs +++ b/tests/shared_dict_nginx.rs @@ -188,36 +188,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -241,36 +241,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -294,36 +294,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -347,36 +347,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -415,36 +415,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -479,36 +479,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -545,36 +545,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -603,36 +603,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -859,36 +859,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -921,36 +921,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1079,36 +1079,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1135,36 +1135,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1193,36 +1193,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1249,36 +1249,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1319,36 +1319,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1412,36 +1412,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1466,36 +1466,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1525,36 +1525,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1785,36 +1785,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -1960,36 +1960,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -2036,36 +2036,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -2110,36 +2110,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } @@ -2170,36 +2170,36 @@ use ngx; fn sv_text(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn sv_number(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } fn sv_some(value: Option) -> bool { match value { - Option::Some(_) => true, - Option::None => false + Some(_) => true, + None => false } } fn sv_bool(value: Option) -> bool { match value { - Option::Some(entry) => entry.bool_value.unwrap_or(false), - Option::None => false + Some(entry) => entry.bool_value.unwrap_or(false), + None => false } } fn sv_float(value: Option) -> number { match value { - Option::Some(entry) => entry.float_value.unwrap_or(0.0), - Option::None => 0.0 + Some(entry) => entry.float_value.unwrap_or(0.0), + None => 0.0 } } diff --git a/tests/test_release_packaging.py b/tests/test_release_packaging.py index 74c166c..dea5b48 100644 --- a/tests/test_release_packaging.py +++ b/tests/test_release_packaging.py @@ -89,7 +89,7 @@ def directory_payload(path: Path) -> dict[str, bytes]: } -FROZEN_RUSTSCRIPT_REV = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" +FROZEN_RUSTSCRIPT_REV = "2f433edab3f1907e8cb060e901357d7e2af016ce" STALE_RUSTSCRIPT_PINS = ( "f5f71eb", "f5f71ebc2f38e276c35f2aebaf63f4e2780efe99", diff --git a/tests/timer_nginx.rs b/tests/timer_nginx.rs index 45a650a..64c0304 100644 --- a/tests/timer_nginx.rs +++ b/tests/timer_nginx.rs @@ -217,15 +217,15 @@ use ngx; fn text_of(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn number_of(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } let d = ngx::shared::dict("timers"); @@ -433,15 +433,15 @@ use ngx; fn text_of(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn number_of(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } let d = ngx::shared::dict("timers"); @@ -765,15 +765,15 @@ use ngx; fn text_of(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn number_of(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } let d = ngx::shared::dict("timers"); @@ -902,15 +902,15 @@ use ngx; fn text_of(value: Option) -> string { match value { - Option::Some(entry) => entry.text_value.unwrap_or(""), - Option::None => "" + Some(entry) => entry.text_value.unwrap_or(""), + None => "" } } fn number_of(value: Option) -> number { match value { - Option::Some(entry) => entry.int_value.unwrap_or(0), - Option::None => 0 + Some(entry) => entry.int_value.unwrap_or(0), + None => 0 } } let d = ngx::shared::dict("timers"); From 03ac0357a3e30861bd4f9a8ad2489d57198d883c Mon Sep 17 00:00:00 2001 From: Alliumcepa Triplef Date: Mon, 16 Nov 2026 04:40:44 +0800 Subject: [PATCH 2/2] docs: use current Some/None syntax --- docs/api/codec.md | 4 ++-- docs/api/ctx.md | 8 ++++---- docs/api/index.md | 8 ++++---- docs/api/request.md | 8 ++++---- docs/api/response.md | 2 +- docs/api/shared-dict.md | 6 +++--- docs/api/standard-async.md | 6 +++--- docs/api/time.md | 2 +- docs/examples/rate-limit.md | 2 +- docs/host-descriptors.md | 2 +- docs/ngx-api-compatibility.md | 4 ++-- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/api/codec.md b/docs/api/codec.md index 0e311b5..f6a1254 100644 --- a/docs/api/codec.md +++ b/docs/api/codec.md @@ -27,8 +27,8 @@ struct DecodedArgsResult { | `ngx.encode_args` | `ngx::encode_args(args: unknown) -> string` | adapted | `PHASE_ENCODE_ARGS` | 1024 pairs; input/output caps | Catalog type is `unknown` because object literals are not an exact map schema; runtime requires a map. Array values emit repeated keys. `true` is a bare key; `false`/`()` omitted. Nested maps/arrays-as-single-value rejected. Duplicate map keys overwrite; use arrays for multi-value keys. Not allowed in `init` / `init_worker`. | `tests/ngx_codec.rs` (`encode_args_*`) | | `ngx.decode_args` | `ngx::decode_args(query: string, max_args: unknown) -> DecodedArgsResult` | adapted | `PHASE_DECODE_ARGS` | default 100; hard max 1024 | Returns fields `args: array` and `truncated: bool`. See cross-cutting item 4. `max_args` is `()` or int. | `tests/ngx_codec.rs` (`decode_args_*`) | | `ngx.encode_base64` | `ngx::encode_base64(input: unknown, no_padding: unknown) -> string` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input/output caps | `input` is string or bytes. `no_padding` is `()`/`false` or `true`. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) | -| `ngx.decode_base64` | `ngx::decode_base64(text: string) -> Option` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Invalid input is `Option::None`, not an error. Padding may be omitted. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) | -| `ngx.decode_base64mime` | `ngx::decode_base64mime(text: string) -> Option` | adapted | `PHASE_CODEC_MISC` | input cap | Skips non-alphabet bytes; stops at first `=`. `data_len % 4 == 1` is `Option::None`. **Not** allowed in `ssl_client_hello` (OpenResty v0.10.29 exception). | `tests/ngx_codec.rs` (`decode_base64mime_*`), `tests/host_catalog.rs` | +| `ngx.decode_base64` | `ngx::decode_base64(text: string) -> Option` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Invalid input is `None`, not an error. Padding may be omitted. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) | +| `ngx.decode_base64mime` | `ngx::decode_base64mime(text: string) -> Option` | adapted | `PHASE_CODEC_MISC` | input cap | Skips non-alphabet bytes; stops at first `=`. `data_len % 4 == 1` is `None`. **Not** allowed in `ssl_client_hello` (OpenResty v0.10.29 exception). | `tests/ngx_codec.rs` (`decode_base64mime_*`), `tests/host_catalog.rs` | | `ngx.crc32_short` | `ngx::crc32_short(data: string) -> int` | supported | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | IEEE CRC-32. Currently matches `crc32_long`. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) | | `ngx.crc32_long` | `ngx::crc32_long(data: string) -> int` | supported | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Same result as `crc32_short` in this release. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) | | `ngx.hmac_sha1` | `ngx::hmac_sha1(secret: string, data: string) -> bytes` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap on each arg | Raw digest **bytes**, not hex. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) | diff --git a/docs/api/ctx.md b/docs/api/ctx.md index 3a7faf6..3ef6c2c 100644 --- a/docs/api/ctx.md +++ b/docs/api/ctx.md @@ -5,16 +5,16 @@ `ngx.ctx` is adapted as four explicit hosts rather than a Lua table. The map is owned by `AccessExec` (request lifetime). Values are `string`; a callable or any non-string value is rejected. Empty and embedded-NUL keys are -rejected. `delete` returns `Option`: `Option::Some(removed)` or -`Option::None` when the key is missing (OpenResty uses `ngx.ctx.key = nil`). +rejected. `delete` returns `Option`: `Some(removed)` or +`None` when the key is missing (OpenResty uses `ngx.ctx.key = nil`). Configuration phases cannot import these hosts. Capability is `RequestCtx` only — ctx hosts do not read the request pointer. | OpenResty API | RustScript callable | Status | Phases | Limits | Semantic differences | Acceptance | | --- | --- | --- | --- | --- | --- | --- | -| `ngx.ctx` | `ngx::ctx::get(key: string) -> Option` | adapted | `PHASE_CTX` | missing → `Option::None` | Explicit get; missing is `Option::None`, a stored empty string is `Option::Some("")`. | `tests/ngx_request_ctx.rs` | +| `ngx.ctx` | `ngx::ctx::get(key: string) -> Option` | adapted | `PHASE_CTX` | missing → `None` | Explicit get; missing is `None`, a stored empty string is `Some("")`. | `tests/ngx_request_ctx.rs` | | `ngx.ctx` | `ngx::ctx::set(key: string, value: string) -> ()` | adapted | `PHASE_CTX` | 256 keys; 256-byte key; 8192-byte value | Failed set leaves the previous value intact. | `tests/ngx_request_ctx.rs` | -| `ngx.ctx` | `ngx::ctx::delete(key: string) -> Option` | adapted | `PHASE_CTX` | same key policy | Returns `Option::Some(removed)` or `Option::None` if missing. | `tests/ngx_request_ctx.rs` | +| `ngx.ctx` | `ngx::ctx::delete(key: string) -> Option` | adapted | `PHASE_CTX` | same key policy | Returns `Some(removed)` or `None` if missing. | `tests/ngx_request_ctx.rs` | | `ngx.ctx` | `ngx::ctx::clear() -> ()` | adapted | `PHASE_CTX` | — | Drops every entry. OpenResty would assign a new table. | `tests/ngx_request_ctx.rs` | `PHASE_CTX` (OpenResty v0.10.29 `ngx.ctx` contexts): `set`, `rewrite`, diff --git a/docs/api/index.md b/docs/api/index.md index 08be7ea..d777171 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -67,13 +67,13 @@ pd-vm I/O, HTTP, and SQLite hosts are not part of the 199 ngx names; see | Acceptance | Tests that exercise the host or family | Catalog type labels: `number` (int or float), `int`, `string`, `bytes`, -`bool`, `()`, `array`, `Option` (`Option::Some(T)` or `Option::None`), +`bool`, `()`, `array`, `Option` (`Some(T)` or `None`), `Result`, named records, and `resource` (typed VM handle). A host output never carries `unknown`, `null`, or the legacy `optional` schema. The pinned compiler matches host arity exactly. OpenResty optional trailing arguments are explicit arguments: pass `()` where the default is -wanted. Absence in a result is `Option::None`, never `null`. +wanted. Absence in a result is `None`, never `null`. ## Inventory @@ -186,13 +186,13 @@ host adds a further difference. `ArgEntry { name: string, value: Option }`. `max_args` of `()` defaults to 100; `0` is clamped to the hard max 1024 (not unbounded); values above 1024 are rejected. A key without `=` carries - `Option::None`; a present empty value is `Option::Some("")`. Repeated + `None`; a present empty value is `Some("")`. Repeated keys repeat the entry. Empty keys are skipped. Invalid `%` sequences are left as-is. 5. **Byte versus string results.** Hex `ngx::md5` returns `string`. `ngx::md5_bin`, `ngx::sha1_bin`, and `ngx::hmac_sha1` return `bytes`. `ngx::decode_base64` / `ngx::decode_base64mime` return - `Option` (`Option::None` on invalid input). `ngx::unescape_uri` returns a string even + `Option` (`None` on invalid input). `ngx::unescape_uri` returns a string even when decoded bytes are not UTF-8 (each byte becomes `char::from`). 6. **Time cache / update boundary.** Time hosts use a process-local cached clock, not nginx `ngx_time` / `ngx_timeofday`. Reads reuse the diff --git a/docs/api/request.md b/docs/api/request.md index c582a0d..25e23c5 100644 --- a/docs/api/request.md +++ b/docs/api/request.md @@ -22,15 +22,15 @@ struct RequestArgsResult { | OpenResty API | RustScript callable | Status | Phases | Limits | Semantic differences | Acceptance | | --- | --- | --- | --- | --- | --- | --- | | `ngx.req.get_method` | `ngx::req::get_method() -> string` | supported | `PHASE_REQ_GET_METHOD` | 256-byte method token | Custom methods keep the textual token. | `tests/ngx_request_read.rs` | -| `ngx.req.http_version` | `ngx::req::http_version() -> Option` | adapted | `PHASE_REQ_HTTP_VERSION` | none | `0.9`/`1.0`/`1.1`/`2.0`/`3.0`, or `Option::None` if unrecognized. | `tests/ngx_request_read.rs` | +| `ngx.req.http_version` | `ngx::req::http_version() -> Option` | adapted | `PHASE_REQ_HTTP_VERSION` | none | `0.9`/`1.0`/`1.1`/`2.0`/`3.0`, or `None` if unrecognized. | `tests/ngx_request_read.rs` | | `ngx.req.raw_header` | `ngx::req::raw_header(no_request_line: unknown) -> string` | adapted | `PHASE_REQ_HTTP_VERSION` | 65536-byte reconstruction | Reconstructs from the **main** request connection header buffer and busy chain (OpenResty v0.10.29). Validates every pointer/range and rejects HTTP/2 (`r->main->stream`) and HTTP/3 (`http_version` 3.0 or non-null `v3_parse`) using main-request protocol truth. Parser NULs restore to `:` and CR/LF. Preread body after CRLFCRLF is stripped. `no_request_line` is `()`/`false`/`true`. Malformed ranges, null buffers, cycles, and over-cap copies are host errors. | `tests/ngx_request_read.rs` (`raw_header_*`) | | `ngx.req.get_headers` | `ngx::req::get_headers(max_headers: unknown, raw: unknown) -> RequestHeadersResult` | adapted | `PHASE_REQ_GET_HEADERS` | default 100; hard 1024; 8192-byte field; 65536-byte total | Fixed fields `headers: array` and `truncated: bool`, where `HeaderEntry { name: string, value: string }`. `raw` `true` keeps original names; otherwise lowercase. Duplicate names repeat the entry. Empty values kept. `hash==0` skipped. Count/byte caps set `truncated=true` before further copy. Null elts with `nelts>0`, cycles, and impossible metadata are host errors, not silent truncation. | `tests/ngx_request_read.rs` | | `ngx.req.get_uri_args` | `ngx::req::get_uri_args(max_args: unknown) -> RequestArgsResult` | adapted | `PHASE_REQ_GET_URI_ARGS` | default 100; hard 1024; 65536-byte query | Fixed fields `args: array` and `truncated: bool`; `ArgEntry { name: string, value: Option }`. Uses the crate-private `decode_query_args` helper shared with `ngx::decode_args`. Trailing empty `&` at max_args is not truncated. `0` clamps to 1024. | `tests/ngx_request_read.rs`, `tests/ngx_codec.rs` | | `ngx.req.get_post_args` | `ngx::req::get_post_args(max_args: unknown) -> RequestArgsResult` | adapted | `PHASE_REQ_GET_POST_ARGS` | same arg caps; 65536-byte body | Sync parse after `read_body` completion from memory **or** a bounded temp file. Fixed fields `args: array` and `truncated: bool`, where `ArgEntry { name: string, value: Option }`. Duplicate keys repeat the entry. Unread, still-reading, discarded, incomplete, or corrupt bodies are structured host errors. Does not delete NGINX temp files. Never initiates body read or yield. | `tests/ngx_request_body.rs` | | `ngx.req.read_body` | `ngx::req::read_body() -> ()` | adapted | `PHASE_REQ_READ_BODY` | async; rewrite/access/content | Calls `ngx_http_read_client_request_body` through a C shim. Undoes that API's `r->main->count++` for `NGX_OK`/`NGX_AGAIN` so the phase driver (content `NGX_DONE` / access `NGX_AGAIN`) owns count. Premature client close (`c->error` / confirmed EOF) is `499`; timeout stays `408`; protocol/`413` statuses are preserved. A C read-event wrapper peeks EOF then finalizes `499` once, otherwise invokes NGINX's original body handler. Generation-safe `nginx_op` cell: callback completes once; cleanup cancels once; stale callbacks no-op. Futures hold no request/VM/module pointers. Idempotent after completion. Forbidden in Log. | `tests/ngx_request_body.rs`, `tests/lifecycle.rs` | | `ngx.req.discard_body` | `ngx::req::discard_body() -> ()` | adapted | `PHASE_REQ_READ_BODY` | sync; rewrite/access/content | Calls `ngx_http_discard_request_body`. Never waits. Idempotent (`NGX_OK`/`NGX_AGAIN`). Discard-after-read is a no-op; read-after-discard completes immediately. Forbidden in Log. | `tests/ngx_request_body.rs` | -| `ngx.req.get_body_data` | `ngx::req::get_body_data() -> Option` | adapted | `PHASE_REQ_GET_BODY_DATA` | 65536-byte copy | Nullary like OpenResty. Owned copy of in-memory buffers. File-backed returns `Option::None`. Empty memory buffers are skipped; inverted ranges and cycles are host errors. Allowed in Log (completed-body getter). | `tests/ngx_request_body.rs` | -| `ngx.req.get_body_file` | `ngx::req::get_body_file() -> Option` | adapted | `PHASE_REQ_GET_BODY_FILE` | 4096-byte path | Owned copy of NGINX temp-file path. Memory-backed returns `Option::None`. Does not delete the file. Forbidden in Log. | `tests/ngx_request_body.rs` | +| `ngx.req.get_body_data` | `ngx::req::get_body_data() -> Option` | adapted | `PHASE_REQ_GET_BODY_DATA` | 65536-byte copy | Nullary like OpenResty. Owned copy of in-memory buffers. File-backed returns `None`. Empty memory buffers are skipped; inverted ranges and cycles are host errors. Allowed in Log (completed-body getter). | `tests/ngx_request_body.rs` | +| `ngx.req.get_body_file` | `ngx::req::get_body_file() -> Option` | adapted | `PHASE_REQ_GET_BODY_FILE` | 4096-byte path | Owned copy of NGINX temp-file path. Memory-backed returns `None`. Does not delete the file. Forbidden in Log. | `tests/ngx_request_body.rs` | | `ngx.req.set_body_data` | `ngx::req::set_body_data(data: string) -> ()` | adapted | `PHASE_REQ_SET_BODY` | 65536-byte memory body | Transactionally allocates a complete `ngx_http_request_body_t` / chain / buf plus bytes from the request pool, then swaps `r->request_body` only after Content-Length (real header hash, linked duplicates updated, dedicated pointer coherent) and chunked/Transfer-Encoding hide-hash sync succeed. Empty body installs a zero-length memory buf. Prior body remains on allocation failure. Rejected in Log, without `RequestWrite`/live request, while `reading_body`/`discard_body`/`header_sent`, while a read-body wait is armed, and on subrequests (`r != r->main`). | `tests/ngx_request_body_mutation.rs` | | `ngx.req.set_body_file` | `ngx::req::set_body_file(path: string, auto_clean: unknown) -> ()` | adapted | `PHASE_REQ_SET_BODY` | 4096-byte path; 65536-byte file | `lstat` then `O_NOFOLLOW\|O_CLOEXEC\|O_NONBLOCK` open; post-open `fstat` must stay a regular file with the same `st_dev`/`st_ino` as `lstat`. Regular files only (symlink/dir/FIFO rejected before open). `auto_clean` `()`/`false` leaves the source path; `true` copies into a private temp. A C `ngx_pool_cleanup_add` handler (`ngx_pool_delete_file` vs `ngx_pool_cleanup_file`) owns the fd: unlink the copy exactly once when `auto_clean`, close once, never unlink the caller source. Errors before cleanup registration leave fd with the caller; after registration a failed header commit nulls the handler. File buf matches OpenResty: `rb->buf=NULL`, `in_file`/`last_buf`/`last_in_chain`, no `temp_file` bit. Content-Length uses the real header hash so proxy hide-hash emits exactly one CL; Transfer-Encoding chain entries keep the hide-hash and are emptied. | `tests/ngx_request_body_mutation.rs` | | `ngx.req.init_body` | `ngx::req::init_body(buffer_size: unknown) -> ()` | adapted | `PHASE_REQ_SET_BODY` | default/hard cap 65536 | Request-owned builder in `RequestPhaseCtx` (test fallback only without module ctx). `()` uses the default cap; integer must be `0..=65536`. Repeated init resets the builder. Does not mutate NGINX body until `finish_body`. | `tests/ngx_request_body_mutation.rs` | @@ -40,7 +40,7 @@ struct RequestArgsResult { | `ngx.req.start_time` | `ngx::req::start_time() -> float` | supported | `PHASE_REQ_FLAGS` | none | `start_sec + start_msec/1000`. | `tests/ngx_request_read.rs` | | `ngx.is_subrequest` | `ngx::is_subrequest() -> bool` | supported | `PHASE_REQ_FLAGS` | none | `r != r->main`. Live false-path on main requests (`REQ_SUB=false`). `ngx_http_core_access_phase` skips all access handlers when `r != r->main`, so SSI/mirror/auth_request subrequests cannot run `access_by_rss_file`. True is stub-covered; SSI include still returns `sub-ok` as evidence the subrequest ran. | `tests/ngx_request_read.rs` | | `ngx.headers_sent` | `ngx::headers_sent() -> bool` | supported | `PHASE_HEADERS_SENT` | none | Live C `r->header_sent` via `ngx_rustscript_request_headers_sent`. Access-phase scripts observe `false`. | `tests/ngx_request_read.rs`, `tests/ngx_request_abi.rs` | -| `ngx.var.VARIABLE` | `ngx::var::get(name: string) -> Option` | adapted | `PHASE_VAR_GET` | 1024-byte name; 65536-byte value | Indexed lookup with `ngx_hash_strlow`. Missing is `Option::None`; present empty is `Option::Some("")`. Rejects empty/NUL names. | `tests/ngx_request_read.rs` (`var_get_*`) | +| `ngx.var.VARIABLE` | `ngx::var::get(name: string) -> Option` | adapted | `PHASE_VAR_GET` | 1024-byte name; 65536-byte value | Indexed lookup with `ngx_hash_strlow`. Missing is `None`; present empty is `Some("")`. Rejects empty/NUL names. | `tests/ngx_request_read.rs` (`var_get_*`) | | `ngx.req.set_method` | `ngx::req::set_method(method_id: int) -> ()` | adapted | `PHASE_REQ_SET_METHOD` | OpenResty method IDs only | Pool-owned canonical `method_name` is allocated successfully before numeric/text fields change. Allocation failure leaves method untouched. Unsupported IDs fail before mutation. | `tests/ngx_request_mutation.rs`, `tests/ngx_task7_hardening.rs` | | `ngx.req.set_uri` | `ngx::req::set_uri(uri: string, jump: unknown) -> ()` | adapted | `PHASE_REQ_SET_URI` | 65536-byte URI | `jump` `()`/`false` rewrites `r->uri`, sets `internal`, clears `valid_unparsed_uri`/`valid_location`/`uri_changed`, and calls `ngx_http_set_exten` via the C shim. `jump=true` is rejected **before** mutation. Empty/unsafe bytes (0x00-0x08, 0x0A-0x1F, 0x7F) fail first. | `tests/ngx_request_mutation.rs` | | `ngx.req.set_uri_args` | `ngx::req::set_uri_args(args: unknown) -> ()` | adapted | `PHASE_REQ_SET_URI` | 65536-byte encoded args | String: escape 0x00-0x20 and 0x7F as `%XX`. Map: reuse `encode_args`. Pool-owned `r->args`; `valid_unparsed_uri=0`. | `tests/ngx_request_mutation.rs` | diff --git a/docs/api/response.md b/docs/api/response.md index eb958f0..4aed37b 100644 --- a/docs/api/response.md +++ b/docs/api/response.md @@ -13,7 +13,7 @@ Content-Type/Length/Location/Last-Modified/ETag. | --- | --- | --- | --- | --- | --- | --- | | `ngx.status` | `ngx::status::get() -> int` | adapted | `PHASE_RESPONSE_META` | none | Prefers `err_status`, then `headers_out.status`, then HTTP/0.9 maps to `9`. Unset HTTP/1.x is `0`. Capability `ResponseRead`. Allowed in `log_by_rss_file`. | `tests/ngx_request_mutation.rs`, `tests/log_config.rs` | | `ngx.status` | `ngx::status::set(status: int) -> ()` | adapted | `PHASE_RESPONSE_META` | 0-999 | Rejected after headers sent. Capability `ResponseWrite`. Rejected by `log_by_rss_file`. | `tests/ngx_request_mutation.rs`, `tests/log_config.rs` | -| `ngx.header.HEADER` | `ngx::header::get(name: string) -> Option` | adapted | `PHASE_RESPONSE_META` | 256-byte token | Missing is `Option::None`; duplicate names yield the first value. Owned copies. Content-Type/Content-Length prefer dedicated fields. Capability `ResponseRead`. Allowed in `log_by_rss_file`. | `tests/ngx_request_mutation.rs`, `tests/log_config.rs` | +| `ngx.header.HEADER` | `ngx::header::get(name: string) -> Option` | adapted | `PHASE_RESPONSE_META` | 256-byte token | Missing is `None`; duplicate names yield the first value. Owned copies. Content-Type/Content-Length prefer dedicated fields. Capability `ResponseRead`. Allowed in `log_by_rss_file`. | `tests/ngx_request_mutation.rs`, `tests/log_config.rs` | | `ngx.header.HEADER` | `ngx::header::set(name: string, value: unknown) -> ()` | adapted | `PHASE_RESPONSE_META` | 8192-byte value | `()` clears. Injection (CRLF/NUL/non-token) rejected. Relative Location does not set the dedicated pointer. New list slots are allocated before old matching names are deactivated. Capability `ResponseWrite`. Rejected by `log_by_rss_file`. | `tests/ngx_request_mutation.rs` | | — | `ngx::header::set_all(headers: map) -> ()` | adapted | `PHASE_RESPONSE_META` | same | Validate every pair first. Allocate the intended representation, then deactivate previous headers. Validation or allocation failure leaves the logical list unchanged (pool memory is not rolled back). | `tests/ngx_request_mutation.rs` | | — | `ngx::header::clear() -> ()` | adapted | `PHASE_RESPONSE_META` | — | Hash-zero every output header and reset dedicated fields. | `tests/ngx_request_mutation.rs` | diff --git a/docs/api/shared-dict.md b/docs/api/shared-dict.md index 8ba7b0e..68a71fd 100644 --- a/docs/api/shared-dict.md +++ b/docs/api/shared-dict.md @@ -26,7 +26,7 @@ struct SharedValue { } ``` -Exactly one payload matches `kind`. Absence is `Option::None`, never `null`. +Exactly one payload matches `kind`. Absence is `None`, never `null`. Optional `exptime` and `flags` parameters accept `()` for the default. Values are bool, int, float, string, or bytes; `set(..., (), ...)` deletes. `add`/`replace` reject an absent value. Request argument and header bags are @@ -87,7 +87,7 @@ request-owned VMs. | OpenResty API | RustScript callable | Status | Phases | Limits | Semantic differences | Acceptance | | --- | --- | --- | --- | --- | --- | --- | | `ngx.shared.DICT` | `ngx::shared::dict(name: string) -> resource` | adapted | `PHASE_DICT_LOOKUP` | unknown zone is a host error | Typed `ngx.shared.dict` handle, not `ngx.shared.NAME` field | `tests/ngx_shared_dict.rs` | -| `ngx.shared.DICT.get` | `ngx::shared::get(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_GET` | missing → `value: Option::None` | Fields `value`, `flags`, `stale`, `error` | `tests/ngx_shared_dict.rs` | +| `ngx.shared.DICT.get` | `ngx::shared::get(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_GET` | missing → `value: None` | Fields `value`, `flags`, `stale`, `error` | `tests/ngx_shared_dict.rs` | | `ngx.shared.DICT.get_stale` | `ngx::shared::get_stale(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_GET` | stale expired values | `stale` is bool | `tests/ngx_shared_dict.rs` | | `ngx.shared.DICT.set` | `ngx::shared::set(dict, key, value, exptime, flags) -> SharedStoreResult` | adapted | `PHASE_DICT_WRITE` | LRU up to 30 | Fields `ok`, `error`, `forcible` | `tests/ngx_shared_dict.rs` | | `ngx.shared.DICT.safe_set` | `ngx::shared::safe_set(dict, key, value, exptime, flags) -> SharedSafeStoreResult` | adapted | `PHASE_DICT_WRITE` | no eviction | Fields `ok`, `error` | `tests/ngx_shared_dict.rs` | @@ -102,7 +102,7 @@ request-owned VMs. | `ngx.shared.DICT.free_space` | `ngx::shared::free_space(dict) -> int` | adapted | `PHASE_DICT_WRITE` | approximate | Process-local: capacity − used; shm: `pfree * pagesize` | `tests/ngx_shared_dict.rs` | | `ngx.shared.DICT.lpush` | `ngx::shared::lpush(dict, key, value) -> SharedNumberResult` | adapted | `PHASE_DICT_WRITE` | list len ≤ 65536; no LRU eviction | Fields `value`, `error`; bool/`()`/map → `bad value type`; scalar conflict → `value not a list` without mutating the node | `tests/ngx_shared_dict_list.rs` | | `ngx.shared.DICT.rpush` | `ngx::shared::rpush(dict, key, value) -> SharedNumberResult` | adapted | `PHASE_DICT_WRITE` | same | Same result type as lpush; appends | `tests/ngx_shared_dict_list.rs` | -| `ngx.shared.DICT.lpop` | `ngx::shared::lpop(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_WRITE` | decode before unlink | Fields `value`, `flags`, `stale`, `error`; empty/missing → `value: Option::None`; decode failure → `{error: "bad value type"}` and the item stays queued | `tests/ngx_shared_dict_list.rs` | +| `ngx.shared.DICT.lpop` | `ngx::shared::lpop(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_WRITE` | decode before unlink | Fields `value`, `flags`, `stale`, `error`; empty/missing → `value: None`; decode failure → `{error: "bad value type"}` and the item stays queued | `tests/ngx_shared_dict_list.rs` | | `ngx.shared.DICT.rpop` | `ngx::shared::rpop(dict, key) -> SharedGetResult` | adapted | `PHASE_DICT_WRITE` | same | Same result type as lpop; pops tail | `tests/ngx_shared_dict_list.rs` | | `ngx.shared.DICT.llen` | `ngx::shared::llen(dict, key) -> SharedNumberResult` | adapted | `PHASE_DICT_WRITE` | — | Missing/expired → `{value: 0}`; scalar → `value not a list` | `tests/ngx_shared_dict_list.rs` | | `ngx.shared.DICT.flush_all` | `ngx::shared::flush_all(dict) -> ()` | adapted | `PHASE_DICT_WRITE` | LRU; ≤1024 visits/call | Each call first frees already-expired keys (visit-capped), then marks live LRU keys with `expires=1` (visit-capped), then `expire(0)`. Repeated calls make monotonic progress across >1024 keys; one call does not wipe the zone. | `tests/ngx_shared_dict_list.rs` | diff --git a/docs/api/standard-async.md b/docs/api/standard-async.md index 8c63567..845c464 100644 --- a/docs/api/standard-async.md +++ b/docs/api/standard-async.md @@ -21,7 +21,7 @@ A builder that is mutated must be declared `let mut` and passed as The pinned contract uses the guest types, not the VM's internal null value: -- `Option` is a tagged value: `Option::Some(payload)` or `Option::None`. +- `Option` is a tagged value: `Some(payload)` or `None`. Absence is never `null`. - `Result` is a tagged value: `Result::Ok(payload)` or `Result::Err(error)`. `?` propagates inside a `Result`-returning function. @@ -170,8 +170,8 @@ SqliteOpenOptions { } ``` -Omitted `Option` fields normalize to `Option::None`. A present value is -`Option::Some(...)`. +Omitted `Option` fields normalize to `None`. A present value is +`Some(...)`. | Field | Values | Default | | --- | --- | --- | diff --git a/docs/api/time.md b/docs/api/time.md index 674626e..e049bb8 100644 --- a/docs/api/time.md +++ b/docs/api/time.md @@ -15,7 +15,7 @@ in cross-cutting item 6. | `ngx.utctime` | `ngx::utctime() -> string` | adapted | cached clock | UTC `yyyy-mm-dd hh:mm:ss`. | `tests/ngx_time.rs` (`today_localtime_and_utctime_use_fixed_formats`) | | `ngx.cookie_time` | `ngx::cookie_time(sec: int) -> string` | supported | none beyond conversion | `Thu, 18-Nov-10 11:27:35 GMT`. | `tests/ngx_time.rs` (`http_cookie_and_parse_time_are_fixed`) | | `ngx.http_time` | `ngx::http_time(sec: int) -> string` | supported | none beyond conversion | `Thu, 18 Nov 2010 11:27:35 GMT`. | `tests/ngx_time.rs` (`http_cookie_and_parse_time_are_fixed`) | -| `ngx.parse_http_time` | `ngx::parse_http_time(text: string) -> Option` | adapted | 128-byte input | RFC 822 / RFC 850 / asctime. Invalid or pre-1970 is `Option::None`. Over 128 bytes is a host error, not `null`. | `tests/ngx_time.rs` (`parse_http_time_*`) | +| `ngx.parse_http_time` | `ngx::parse_http_time(text: string) -> Option` | adapted | 128-byte input | RFC 822 / RFC 850 / asctime. Invalid or pre-1970 is `None`. Over 128 bytes is a host error, not `null`. | `tests/ngx_time.rs` (`parse_http_time_*`) | --- diff --git a/docs/examples/rate-limit.md b/docs/examples/rate-limit.md index 20ab554..16e3973 100644 --- a/docs/examples/rate-limit.md +++ b/docs/examples/rate-limit.md @@ -34,7 +34,7 @@ The zone name `"ratelimit"` in the script must match `rss_shared_dict ratelimit ## Algorithm -1. Read `$rate_limit_key` via `ngx::var::get(...).unwrap_or("")`. Missing (`Option::None`) or empty fails closed with 503. +1. Read `$rate_limit_key` via `ngx::var::get(...).unwrap_or("")`. Missing (`None`) or empty fails closed with 503. 2. Resolve `ngx::shared::dict("ratelimit")`. An unknown zone is a host error (500). 3. Establish a new window with `ngx::shared::safe_add(dict, key, 1, WINDOW_SECONDS, ())` so capacity pressure never evicts a live quota: - `ok` → this is count `1` for a new window; diff --git a/docs/host-descriptors.md b/docs/host-descriptors.md index 81a9ddd..6336ac2 100644 --- a/docs/host-descriptors.md +++ b/docs/host-descriptors.md @@ -61,7 +61,7 @@ Fixed envelopes are catalog `HostTypeSchema::Named` and Rust | `SharedNumberResult` | `ngx::shared::{ttl,lpush,rpush,llen}` | Guest scripts use the host named types. Shared dictionary values are tagged -`SharedValue` records and absence is `Option::None`. +`SharedValue` records and absence is `None`. ## Intentional dynamic parameters diff --git a/docs/ngx-api-compatibility.md b/docs/ngx-api-compatibility.md index ba78736..2010fae 100644 --- a/docs/ngx-api-compatibility.md +++ b/docs/ngx-api-compatibility.md @@ -46,7 +46,7 @@ Multi-return OpenResty values use **fixed result structs** at the RustScript boundary, and every return slot is fully typed: `Option` for logical absence, named structs for fixed shapes, and entry arrays for open-keyed bags. Field access uses `.value` / `.flags` / `.stale` / `.ok` / `.error` / -`.forcible`; an absent logical value is `Option::None`, never `null`. The +`.forcible`; an absent logical value is `None`, never `null`. The VM's internal carrier is not part of the script-facing type. Open-keyed collections are typed entry arrays instead of dynamic maps: @@ -65,7 +65,7 @@ struct RequestHeadersResult { Repeated keys repeat the entry, so duplicate headers and repeated query arguments survive without an `unknown` value. A bare query key carries -`Option::None`; a present empty value carries `Option::Some("")`. +`None`; a present empty value carries `Some("")`. Heterogeneous stored values use a tagged record. Shared-dictionary values are `SharedValue { kind, bool_value, int_value, float_value, text_value,