Skip to content

feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#124

Open
FelicianoAngulo2 wants to merge 3 commits into
feature/phase21_api_symmetryfrom
feat/no-alloc-bare-metal
Open

feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#124
FelicianoAngulo2 wants to merge 3 commits into
feature/phase21_api_symmetryfrom
feat/no-alloc-bare-metal

Conversation

@FelicianoAngulo2

Copy link
Copy Markdown
Contributor

This pull request refactors the server implementation to fully support no-allocator ("no-alloc") builds and adds a new callback mechanism for handling non-Service Discovery (non-SD) SOME/IP unicast datagrams (i.e., method requests). It separates allocator-backed conveniences from the core, making the server feature alloc-free unless explicitly requested. The pull request also updates the subscription handling for bare-metal/no-alloc targets to avoid heap allocations and clarifies the roles of various type aliases and generic parameters.

The most important changes are:

No-alloc support and feature gating

  • The server feature is now alloc-free by default; allocator-backed conveniences (such as heap-allocated buffers and Arc-based handles) are gated behind the _alloc feature. The default handle types (DefaultSocketHandle, DefaultSdStateHandle, DefaultEventPublisherHandle) switch between Arc<T> and &'static T depending on allocator availability. (Cargo.toml [1] src/server/mod.rs [2] [3]
  • The StartedLatch type (used to prevent multiple run-futures from racing) is now Arc<AtomicBool> on alloc builds and &'static AtomicBool on no-alloc builds, ensuring correct ownership and thread-safety for both cases. (src/server/mod.rs [1] [2]

Non-SD SOME/IP datagram callback

  • Introduced an optional non_sd_observer callback (NonSdRequestCallback) to the Server struct and runtime. When set, this callback is invoked for every non-SD unicast datagram received, allowing consumers to handle SOME/IP method requests or fire-and-forget calls. (src/server/mod.rs [1] [2] [3] [4] [5] [6]

Subscription handling for bare-metal/no-alloc

  • The bare-metal (no_std) implementation of SubscriptionHandle now returns core::future::Ready futures instead of boxed heap-allocated futures, eliminating the need for alloc in the no-alloc path. (src/server/subscription_manager.rs [1] [2] [3] [4]

API and type exports

  • Updated the public API to export the new NonSdRequestCallback type and ensure all relevant types are available when the server feature is enabled. (src/lib.rs src/lib.rsL228-R230)

Internal code organization and tests

  • Updated constructor and test code to initialize the new fields (started, non_sd_observer) correctly, and added #[cfg(feature = "_alloc")] guards to allocator-specific methods. (src/server/mod.rs [1] [2] [3] [4] [5]

These changes improve flexibility and portability for embedded and bare-metal targets, while also making the server more extensible for advanced SOME/IP use cases.

@FelicianoAngulo2 FelicianoAngulo2 self-assigned this Jun 1, 2026

@JustinKovacich JustinKovacich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, I hope this is helpful. I've made a couple code quality requests/suggestions.

Comment thread src/server/runtime.rs Outdated
Comment thread src/server/runtime.rs

@JustinKovacich JustinKovacich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FelicianoAngulo2 FelicianoAngulo2 force-pushed the feature/phase21_api_symmetry branch 2 times, most recently from 9cafba0 to 892cb5b Compare June 8, 2026 14:46
Feliciano Angulo and others added 3 commits June 8, 2026 10:51
…estCallback

Two related changes to land the no-alloc bare-metal server path:
1.  drop _alloc from the server feature and gate every alloc usage (use alloc::sync::Arc, Wrappable handles, SocketOptions, sd-protocol import, run_inner's 64 KiB vec! and new_with_deps/new_passive_with_deps' Arc-wrap constructors) so client+server+bare_metal builds with zero __rust_alloc/__rg_alloc symbol references. The Server struct's started latch is now a feature-gated StartedLatch type alias (Arc<AtomicBool> under _alloc, &'static AtomicBool on bare metal) passed through ServerStorage; the H/Hsd/Hep default generics use cfg'd DefaultSocketHandle/DefaultSdStateHandle/DefaultEventPublisherHandle aliases so Arc names don't need to resolve under no-alloc. StaticSubscriptionHandle returns core::future::Ready instead of alloc::boxed::Box::pin (the lock closures are synchronous).
2. Add NonSdRequestCallback fn-pointer on ServerStorage/Server, threaded through run_with_buffers/run_combined/recv_loop, invoked in place of the historical 'non-SD ignored' branch — surfaces method requests / fire-and-forget calls (e.g. halo's HWP1* requests) to the consumer FFI without requiring a ChannelFactory-backed ServerUpdates channel.
add non-SD observer support and no-alloc witness tests
Co-authored-by: Justin Kovacich <32140377+JustinKovacich@users.noreply.github.com>
@FelicianoAngulo2 FelicianoAngulo2 force-pushed the feat/no-alloc-bare-metal branch from d198b30 to 64fcc08 Compare June 8, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants