xref: /aosp_15_r20/bootable/libbootloader/gbl/libbootimg/src/lib.rs (revision 5225e6b173e52d2efc6bcf950c27374fd72adabc)
1*5225e6b1SAndroid Build Coastguard Worker // Copyright 2023, The Android Open Source Project
2*5225e6b1SAndroid Build Coastguard Worker //
3*5225e6b1SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*5225e6b1SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*5225e6b1SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*5225e6b1SAndroid Build Coastguard Worker //
7*5225e6b1SAndroid Build Coastguard Worker //     http://www.apache.org/licenses/LICENSE-2.0
8*5225e6b1SAndroid Build Coastguard Worker //
9*5225e6b1SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*5225e6b1SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*5225e6b1SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*5225e6b1SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*5225e6b1SAndroid Build Coastguard Worker // limitations under the License.
14*5225e6b1SAndroid Build Coastguard Worker 
15*5225e6b1SAndroid Build Coastguard Worker //! GBL build wrapper for the Android boot image library:
16*5225e6b1SAndroid Build Coastguard Worker //! https://cs.android.com/android/platform/superproject/main/+/main:system/tools/mkbootimg/rust/.
17*5225e6b1SAndroid Build Coastguard Worker 
18*5225e6b1SAndroid Build Coastguard Worker #![cfg_attr(not(test), no_std)]
19*5225e6b1SAndroid Build Coastguard Worker 
20*5225e6b1SAndroid Build Coastguard Worker #[rustfmt::skip]
21*5225e6b1SAndroid Build Coastguard Worker mod bootimg;
22*5225e6b1SAndroid Build Coastguard Worker pub use bootimg::*;
23*5225e6b1SAndroid Build Coastguard Worker pub use bootimg_bindgen as defs;
24*5225e6b1SAndroid Build Coastguard Worker 
25*5225e6b1SAndroid Build Coastguard Worker use liberror::Error;
26*5225e6b1SAndroid Build Coastguard Worker 
27*5225e6b1SAndroid Build Coastguard Worker impl From<ImageError> for Error {
from(err: ImageError) -> Error28*5225e6b1SAndroid Build Coastguard Worker     fn from(err: ImageError) -> Error {
29*5225e6b1SAndroid Build Coastguard Worker         match err {
30*5225e6b1SAndroid Build Coastguard Worker             ImageError::BufferTooSmall => Error::BufferTooSmall(None),
31*5225e6b1SAndroid Build Coastguard Worker             ImageError::BadMagic => Error::BadMagic,
32*5225e6b1SAndroid Build Coastguard Worker             ImageError::UnexpectedVersion => Error::UnsupportedVersion,
33*5225e6b1SAndroid Build Coastguard Worker             _ => Error::Other(None),
34*5225e6b1SAndroid Build Coastguard Worker         }
35*5225e6b1SAndroid Build Coastguard Worker     }
36*5225e6b1SAndroid Build Coastguard Worker }
37