xref: /aosp_15_r20/development/tools/external_crates/name_and_version/src/lib.rs (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1 // Copyright (C) 2024 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! A name and version data structure that can be used as map key.
16 
17 use semver::Version;
18 use thiserror::Error;
19 
20 pub use self::name_and_version::{NameAndVersion, NameAndVersionRef, NamedAndVersioned};
21 mod name_and_version;
22 
23 pub use self::name_and_version_map::{
24     crates_with_multiple_versions, crates_with_single_version, most_recent_version,
25     NameAndVersionMap,
26 };
27 mod name_and_version_map;
28 
29 #[allow(missing_docs)]
30 #[derive(Error, Debug)]
31 pub enum Error {
32     #[error("Duplicate crate version: {0} {1}")]
33     DuplicateVersion(String, Version),
34     #[error("Version parse error")]
35     VersionParseError(#[from] semver::Error),
36     #[error("Unknown error")]
37     Unknown,
38 }
39