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.13k stars 49 forks source link

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

Closed Totodore closed 1 week ago

Totodore commented 1 week 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.