MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / charge

Function charge

atomic-core/src/change/format_v3/graph_fields/wire.rs:23–29  ·  view source on GitHub ↗
(budget: &mut usize, count: usize, cost: usize)

Source from the content-addressed store, hash-verified

21 }
22}
23pub(super) fn charge(budget: &mut usize, count: usize, cost: usize) -> FormatResult<()> {
24 *budget = count
25 .checked_mul(cost)
26 .and_then(|n| budget.checked_sub(n))
27 .ok_or(FormatError::GraphFieldLimitExceeded)?;
28 Ok(())
29}
30pub(super) fn put(out: &mut Vec<u8>, mut n: u64) {
31 while n >= 128 {
32 out.push((n as u8) | 128);

Callers 8

pathMethod · 0.70
auxMethod · 0.70
insertionMethod · 0.70
edgesMethod · 0.70
encodeFunction · 0.70
parseMethod · 0.70
countMethod · 0.70
pathMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected