File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,10 +8,9 @@ homepage = { workspace = true }
88license = { workspace = true }
99
1010[dependencies ]
11- wincode = { version = " 0.4.4" , features = [" derive" ] }
1211solana-address = { version = " 2.2.0" , features = [" wincode" ] }
13-
1412spl-pod = { version = " 0.8.0" , features = [" wincode" ] }
13+ wincode = { version = " 0.4.4" , features = [" derive" ] }
1514
1615[dev-dependencies ]
1716bincode = " 1.3.3"
Original file line number Diff line number Diff line change @@ -79,12 +79,6 @@ pub enum StakeStateV2Tag {
7979impl StakeStateV2Tag {
8080 pub const TAG_LEN : usize = size_of :: < PodU32 > ( ) ;
8181
82- #[ inline]
83- pub ( crate ) fn from_u32 ( v : u32 ) -> Result < Self , StakeStateError > {
84- Self :: assert_valid_tag ( v) ?;
85- Ok ( unsafe { core:: mem:: transmute :: < u32 , StakeStateV2Tag > ( v) } )
86- }
87-
8882 #[ inline]
8983 pub ( crate ) unsafe fn from_u32_unchecked ( v : u32 ) -> Self {
9084 debug_assert ! ( v <= Self :: RewardsPool as u32 ) ;
@@ -105,7 +99,17 @@ impl StakeStateV2Tag {
10599 return Err ( StakeStateError :: UnexpectedEof ) ;
106100 }
107101 let raw = u32:: from_le_bytes ( bytes[ ..Self :: TAG_LEN ] . try_into ( ) . unwrap ( ) ) ;
108- Self :: from_u32 ( raw)
102+ Self :: try_from ( raw)
103+ }
104+ }
105+
106+ impl TryFrom < u32 > for StakeStateV2Tag {
107+ type Error = StakeStateError ;
108+
109+ #[ inline]
110+ fn try_from ( v : u32 ) -> Result < Self , Self :: Error > {
111+ Self :: assert_valid_tag ( v) ?;
112+ Ok ( unsafe { Self :: from_u32_unchecked ( v) } )
109113 }
110114}
111115
You can’t perform that action at this time.
0 commit comments