<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit-wasm.git/examples/rust/echo-request/src, branch master</title>
<subtitle>Development libraries (C &amp; Rust) for writing WebAssembly modules for NGINX Unit</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/'/>
<entry>
<title>examples/rust: Remove some redundant unsafe blocks</title>
<updated>2025-05-14T19:37:16+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2025-05-14T19:37:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=89900c002afb77366503330b513c2547b6cf1abd'/>
<id>89900c002afb77366503330b513c2547b6cf1abd</id>
<content type='text'>
... as noted by the compiler...

Fixes: 2cf492f ("examples/rust: Fix some new rustc warnings")
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
... as noted by the compiler...

Fixes: 2cf492f ("examples/rust: Fix some new rustc warnings")
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>examples/rust: Fix some new rustc warnings</title>
<updated>2024-07-02T01:49:09+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2024-07-02T01:49:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=2cf492f49cfb05c5083c99a38634c2f40b6d3e84'/>
<id>2cf492f49cfb05c5083c99a38634c2f40b6d3e84</id>
<content type='text'>
With at least

  rustc 1.79.0 (129f3b996 2024-06-10) (Fedora 1.79.0-3.fc40)

We were getting warnings when building the rust examples like

warning: creating a mutable reference to mutable static is discouraged
  --&gt; src/lib.rs:75:40
   |
75 |     let ctx: *mut luw_ctx_t = unsafe { &amp;mut CTX };
   |                                        ^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see issue #114447 &lt;https://github.com/rust-lang/rust/issues/114447&gt;
   = note: this will be a hard error in the 2024 edition
   = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
   = note: `#[warn(static_mut_refs)]` on by default
help: use `addr_of_mut!` instead to create a raw pointer
   |
75 |     let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) };
   |                                        ~~~~~~~~~~~~~~~~~

So do like it says and use the addr_of_mut!() macro.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With at least

  rustc 1.79.0 (129f3b996 2024-06-10) (Fedora 1.79.0-3.fc40)

We were getting warnings when building the rust examples like

warning: creating a mutable reference to mutable static is discouraged
  --&gt; src/lib.rs:75:40
   |
75 |     let ctx: *mut luw_ctx_t = unsafe { &amp;mut CTX };
   |                                        ^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see issue #114447 &lt;https://github.com/rust-lang/rust/issues/114447&gt;
   = note: this will be a hard error in the 2024 edition
   = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
   = note: `#[warn(static_mut_refs)]` on by default
help: use `addr_of_mut!` instead to create a raw pointer
   |
75 |     let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) };
   |                                        ~~~~~~~~~~~~~~~~~

So do like it says and use the addr_of_mut!() macro.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>examples/rust: Do some simplification around unsafe {} blocks</title>
<updated>2023-10-17T18:01:06+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-10-17T17:59:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=9b17f64d301334b999a8138037d32ff72e951018'/>
<id>9b17f64d301334b999a8138037d32ff72e951018</id>
<content type='text'>
We can put the unsafe keyword as part of the function definition,
getting rid of the unsafe {} blocks in the functions themselves.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can put the unsafe keyword as part of the function definition,
getting rid of the unsafe {} blocks in the functions themselves.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>examples/rust: Update for new API additions</title>
<updated>2023-08-30T00:55:26+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-08-30T00:55:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=d62b8e93fdaf62a36c36437f987485f7be36e52f'/>
<id>d62b8e93fdaf62a36c36437f987485f7be36e52f</id>
<content type='text'>
Update the echo-request and upload-reflector examples for the new
uwr_http_add_header_content_type() and uwr_http_add_header_content_len()
functions.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Update the echo-request and upload-reflector examples for the new
uwr_http_add_header_content_type() and uwr_http_add_header_content_len()
functions.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>examples/rust: Reduce the scope of an unsafe block in echo-request</title>
<updated>2023-08-29T22:51:39+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-08-29T22:51:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=71ba509e6d662e1e8e703a7e1e609e1b1f8eb929'/>
<id>71ba509e6d662e1e8e703a7e1e609e1b1f8eb929</id>
<content type='text'>
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libunit-wasm: Remove the idx argument from luw_http_add_header()</title>
<updated>2023-08-28T15:20:26+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-08-28T15:11:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=da5d9dc03b14b4d0f1ce0ce3ff093f387e148706'/>
<id>da5d9dc03b14b4d0f1ce0ce3ff093f387e148706</id>
<content type='text'>
This was used to specify the index of the response header being added,
starting at 0 and incrementing by one for each header.

Instead of having the programmer specify this, track it internally.

We add an extra check in luw_http_add_header() to make sure we aren't
trying to add more headers than we said with luw_http_init_headers(), if
we are, simply return.

This updates the API-C.md and the various examples and 'rusty' API
wrapper.

Suggested-by: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was used to specify the index of the response header being added,
starting at 0 and incrementing by one for each header.

Instead of having the programmer specify this, track it internally.

We add an extra check in luw_http_add_header() to make sure we aren't
trying to add more headers than we said with luw_http_init_headers(), if
we are, simply return.

This updates the API-C.md and the various examples and 'rusty' API
wrapper.

Suggested-by: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Rust: Port the Rust Wasm demos to the new 'rusty' wrappers</title>
<updated>2023-08-25T20:13:49+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-08-24T19:43:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=f9c01f4f721969c7dbe6152bbd38cc039acb27bf'/>
<id>f9c01f4f721969c7dbe6152bbd38cc039acb27bf</id>
<content type='text'>
rusty is a thin wrapper over the generated libunit-wasm bindings to
provide a more native rust like interface.

This gets rid of all the casting and ugly string handling. It massively
reduces the amount of unsafe {} blocks needed, though some still are...

All in all this provides a nice code cleanup.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
rusty is a thin wrapper over the generated libunit-wasm bindings to
provide a more native rust like interface.

This gets rid of all the casting and ugly string handling. It massively
reduces the amount of unsafe {} blocks needed, though some still are...

All in all this provides a nice code cleanup.

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Initial commit</title>
<updated>2023-08-21T22:24:12+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-08-02T16:03:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit-wasm.git/commit/?id=d6ed6a219b31a58526721f96195c80061d41ce54'/>
<id>d6ed6a219b31a58526721f96195c80061d41ce54</id>
<content type='text'>
libunit-wasm and example C and Rust WebAssembly modules for NGINX Unit.

Co-developed-by: Timo Stark &lt;t.stark@nginx.com&gt;
Co-developed-by: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
libunit-wasm and example C and Rust WebAssembly modules for NGINX Unit.

Co-developed-by: Timo Stark &lt;t.stark@nginx.com&gt;
Co-developed-by: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
