nginx / nginx/ngx-rust

Safe wrappers for generic collections

Open
#104 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
915
Forks
96
Avg merge
5d 22h
Merged PRs (30d)
6

Description

In NGINX we have several "generic" collections (in the most C style of generic, with void * or pointer aliasing):

  • ngx_array_t, an array of known-size void * pointers
  • ngx_list_t, a sequence of arrays of void *
  • ngx_queue_t, an intrusive doubly linked list.
  • ngx_rbtree_t, a red-black tree. This structure is used both as intrusive (ngx_event_t.timer of type ngx_rbtree_node_t) and via ngx_rbtree_node_t.data of type void *.
  • ngx_hash_t, a hash table.

All of those should be representable as strictly typed objects, e.g. Array<NgxStr>, List<TableElement>, Hash<HttpHeader> and have the necessary iteration, random access and modification methods. This way we could limit unsafety to the initialization of a collection wrapper.

There's a crate that is useful for implementing such wrappers, foreign-types. It's not necessary, as for Array<T> we can directly cast ngx_array_t.elts.add(i) to *mut T with almost the same level of (un)safety, but it makes certain steps easier and reduces boilerplate code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Rust bindings for ngx_array_t, ngx_list_t, ngx_queue_t, ngx_rbtree_t, and ngx_hash_t, then review whether foreign-types fits their ownership and casting needs. Done means the listed collections have strictly typed wrappers with iteration, access, and modification methods, while unsafety is confined to initialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, nginx, rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.