Mountain/RPC/CocoonService/TreeView/ViewIdHandle.rs
1#![allow(non_snake_case)]
2
3//! Hash a `viewId` string into the same `u32` that
4//! `RegisterTreeViewProvider::Fn` uses as a registration handle. Lets
5//! `GetTreeChildren::Fn` look up the registered provider without the
6//! caller passing the handle through the wire.
7
8pub fn Fn(ViewIdentifier:&str) -> u32 {
9 ViewIdentifier
10 .as_bytes()
11 .iter()
12 .fold(0u32, |Acc, B| Acc.wrapping_mul(31).wrapping_add(*B as u32))
13}