Skip to content

server: drop extern crate alloc requirement (switch Arc<…> storage to &'static borrows) #115

@JustinKovacich

Description

@JustinKovacich

Context

Server holds Arc<EventPublisher<R, Sub, H, T>> and EventPublisher holds Arc<F::Socket>. Both require a global allocator, so the server cargo feature transitively pulls extern crate alloc (gated via the internal _alloc feature).

Pure-no_std consumers without an allocator can use the client feature alone (verified alloc-free under --target thumbv7em-none-eabihf --no-default-features --features client,bare_metal), but the server side currently forces an allocator on the consumer.

Goal

Refactor the server's shared-storage to use &'static borrows instead of Arc<...> so cargo build --target thumbv7em-none-eabihf --no-default-features --features client,server,bare_metal produces an alloc-free rlib.

Approach sketch

The bare-metal-no-alloc constructor path (Server::new_with_handles / new_passive_with_handles) already accepts pre-built &'static T handles via the WrappableSharedHandle<T> blanket on &'static T. The work is on the _with_deps constructors and any internal cloning paths that assume Arc::clone is cheap (SharedHandle::clone() for &'static T is also cheap, but the bound surface differs).

Verification: extend the alloc-symbol audit (tests/no_alloc_witness.rs) to also assert zero __rust_alloc references for --features client,server,bare_metal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions