Skip to content

NgxStr, NgxString require manual creation of ngx_str_t #193

Description

@pchickey

Whether I'm using an NgxStr or NgxString, there is no method that can give me an ngx_str_t - I still have to construct that record out of pointers myself, e.g. let s: NgxStr = ...; let ngx_s: ngx_str_t = ngx_str_t { data: s.as_bytes().ptr(), len: s.len() }.

While it could be unsafe to let the pointer escape the lifetime of the NgxStr (and we have no way to track that because the C FFI type here escapes Rust's lifetime system, its required often enough when calling nginx apis that we should at least make it slightly more convenient.

I think that we can add unsafe fn as_ngx_str(&self) -> ngx_str_t as a method on NgxStr? Or is the right place to add it on NgxString? Not 100% sure, and open to feedback. Maybe there is some reason this method was left out I haven't thought of

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions