pub struct Share(/* private fields */);Expand description
Billionths of the whole plan.
Ordered so a renderer can sort branches by weight without unwrapping the number first.
Implementations§
Sourcepub const WHOLE: Share
pub const WHOLE: Share
The whole plan. The one origin: every other share descends from this one by division.
Sourcepub const NONE: Share
pub const NONE: Share
Nothing at all — what a branch with no leaves has done.
Safe to expose because it cannot grow: no addition exists on this type, so a zero cannot be turned into a claim on the plan.
Sourcepub fn split(self, weights: &[u32]) -> Result<Vec<Share>, AxError>
pub fn split(self, weights: &[u32]) -> Result<Vec<Share>, AxError>
Divides this share among weights, consuming it.
The parts add up to the input exactly. Integer division leaves a remainder of fewer billionths than there are parts, and it goes to the earliest parts one at a time — a rule rather than a rounding, so the same plan divides the same way on every machine.
§Errors
Refuses an empty list and refuses weights that are all zero: both ask for a division with no dividend, and answering them would mean either losing the share or inventing a rule about where it went.