Skip to main content

Mountain/RPC/CocoonService/TreeView/
ViewIdHandle.rs

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