-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f08d21
commit b057c5a
Showing
3 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ name = "mbedtls" | |
# we decided not to support. | ||
version = "0.12.3" | ||
authors = ["Jethro Beekman <[email protected]>"] | ||
build = "build.rs" | ||
build = "build/build.rs" | ||
edition = "2018" | ||
license = "Apache-2.0 OR GPL-2.0-or-later" | ||
description = """ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::fmt; | ||
|
||
pub struct StableCrateId(u64); | ||
|
||
impl StableCrateId { | ||
pub fn new( | ||
crate_name: &str, | ||
is_exe: bool, | ||
mut metadata: Vec<String>, | ||
cfg_version: String, | ||
) -> StableCrateId { | ||
use std::collections::hash_map::DefaultHasher; | ||
use std::hash::{Hash, Hasher}; | ||
|
||
let mut hasher = DefaultHasher::new(); | ||
crate_name.hash(&mut hasher); | ||
|
||
metadata.sort(); | ||
metadata.dedup(); | ||
|
||
hasher.write(b"metadata"); | ||
for s in &metadata { | ||
hasher.write_usize(s.len()); | ||
hasher.write(s.as_bytes()); | ||
} | ||
|
||
hasher.write(if is_exe { b"exe" } else { b"lib" }); | ||
|
||
hasher.write(cfg_version.as_bytes()); | ||
|
||
StableCrateId(hasher.finish() as u64) | ||
} | ||
|
||
pub fn as_u64(self) -> u64 { | ||
self.0 | ||
} | ||
} | ||
|
||
// Implement the LowerHex trait for StableCrateId | ||
impl fmt::LowerHex for StableCrateId { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
fmt::LowerHex::fmt(&self.0, f) | ||
} | ||
} | ||
|
||
impl fmt::Display for StableCrateId { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
// Implement the formatting logic here | ||
// Example: Display the inner value as a hexadecimal string | ||
write!(f, "{:x}", self.0) | ||
} | ||
} |