Totodore / socketioxide

A socket.io server implementation in Rust that integrates with the Tower ecosystem and the Tokio stack.
https://docs.rs/socketioxide
MIT License
1.21k stars 52 forks source link

feat: Namespace key in map as `Str` #342

Closed Totodore closed 3 months ago

Totodore commented 3 months ago

Motivation

Most of the Namespace paths are now Str. It allows to avoid lifetime issue and reduce allocations. To match the use of Str in the codebase we can also switch from a Hashmap<Cow<'static, str>, Namespace> to a Hashmap<Str, Namespace>. Thanks to that there is not only no copying when using 'static str (this was already the case) but also when using owned String. For example with dynamic namespaces or when the user provide owned strings.

Fixes also a minor memory leak where namespaces created from dynamic namespaces were keeping a ref to the namespace path in the connect packet. Thus never freeing the packet.