fuchsia_image_format/lib.rs
1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use anyhow::{anyhow, Error};
6
7mod image_format;
8mod linux_drm;
9
10pub use image_format::*;
11pub use linux_drm::*;
12
13pub fn round_up_to_increment(size: usize, increment: usize) -> Result<usize, Error> {
14 let spare = size % increment;
15 if spare > 0 {
16 size.checked_add(increment - spare).ok_or_else(|| anyhow!("Overflow when adding to size."))
17 } else {
18 Ok(size)
19 }
20}