-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `SpacedStructName` trait provides a textual representation of a struct. Instead of the common pascal case names used in rust, it is intended to provide a lowercase space separated name. Words or acronyms that are capitalized will still be capitalized.
- Loading branch information
1 parent
e8620db
commit ffc227c
Showing
2 changed files
with
45 additions
and
0 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
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,43 @@ | ||
// Copyright (c) 2023 The MobileCoin Foundation | ||
|
||
//! Provides a trait that provides a textual friendly version of a struct name. | ||
//! The names are all lowercase and use spaces between the words. | ||
|
||
use mc_sgx_core_types::{ | ||
Attributes, ConfigId, ConfigSvn, CpuSvn, ExtendedProductId, FamilyId, IsvProductId, IsvSvn, | ||
MiscellaneousSelect, MrEnclave, MrSigner, ReportData, | ||
}; | ||
|
||
macro_rules! spaced_struct_name { | ||
($($item:ident, $name:literal;)*) => {$( | ||
impl SpacedStructName for $item { | ||
fn spaced_struct_name() -> &'static str { | ||
$name | ||
} | ||
} | ||
)*} | ||
} | ||
|
||
/// A textual name of a struct to be used in explanatory text. | ||
/// | ||
/// Instead of the common pascal case names used in rust, a lowercase space | ||
/// separated name is used. Words or acronyms that are capitalized will still be | ||
/// capitalized. | ||
pub trait SpacedStructName { | ||
fn spaced_struct_name() -> &'static str; | ||
} | ||
|
||
spaced_struct_name! { | ||
Attributes, "attributes"; | ||
CpuSvn, "CPU SVN"; | ||
MiscellaneousSelect, "miscellaneous select"; | ||
ExtendedProductId, "extended product ID"; | ||
MrEnclave, "MRENCLAVE"; | ||
MrSigner, "MRSIGNER key hash"; | ||
ConfigId, "config ID"; | ||
IsvProductId, "ISV product ID"; | ||
IsvSvn, "ISV SVN"; | ||
ConfigSvn, "config SVN"; | ||
FamilyId, "family ID"; | ||
ReportData, "report data"; | ||
} |