File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ use crate::part::{
1111 gen3:: { self , Gen3Partition } ,
1212 part:: { GenUnknownPartition , Partition } ,
1313} ;
14+ use crate :: ver:: Version ;
1415
1516#[ derive( Serialize , Deserialize , Clone , Debug ) ]
1617pub enum Partitions {
@@ -70,6 +71,34 @@ impl Partitions {
7071 partitions
7172 }
7273
74+ pub fn get_me_version ( & self ) -> Option < Version > {
75+ match self {
76+ Partitions :: Gen2 ( parts) => {
77+ if let Some ( Gen2Partition :: Dir ( d) ) =
78+ parts. iter ( ) . find ( |p| matches ! ( p, Gen2Partition :: Dir ( _) ) )
79+ {
80+ Some ( d. dir . manifest . header . version )
81+ } else {
82+ None
83+ }
84+ }
85+ Partitions :: Gen3 ( parts) => {
86+ if let Some ( Gen3Partition :: Dir ( d) ) =
87+ parts. iter ( ) . find ( |p| matches ! ( p, Gen3Partition :: Dir ( _) ) )
88+ {
89+ if let Ok ( m) = d. cpd . manifest {
90+ Some ( m. header . version )
91+ } else {
92+ None
93+ }
94+ } else {
95+ None
96+ }
97+ }
98+ _ => None ,
99+ }
100+ }
101+
73102 /// Get ranges not covered by FPT entries.
74103 pub fn non_covered_ranges ( & self ) -> Vec < Range < usize > > {
75104 let mut res = vec ! [ ] ;
You can’t perform that action at this time.
0 commit comments