@@ -884,41 +884,49 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
884
884
Ok ( Attribute :: AllowedMechanisms ( types) )
885
885
}
886
886
AttributeType :: EndDate => {
887
- let date = val. as_ptr ( ) as * const CK_DATE ;
888
- unsafe {
889
- let year = String :: from_utf8_lossy ( Vec :: from ( ( * date) . year ) . as_slice ( ) )
890
- . trim_end ( )
891
- . to_string ( ) ;
892
- let month = String :: from_utf8_lossy ( Vec :: from ( ( * date) . month ) . as_slice ( ) )
893
- . trim_end ( )
894
- . to_string ( ) ;
895
- let day = String :: from_utf8_lossy ( Vec :: from ( ( * date) . day ) . as_slice ( ) )
896
- . trim_end ( )
897
- . to_string ( ) ;
898
- Ok ( Attribute :: EndDate ( Date :: new_from_str_slice (
899
- year. as_str ( ) ,
900
- month. as_str ( ) ,
901
- day. as_str ( ) ,
902
- ) ?) )
887
+ if val. is_empty ( ) {
888
+ Ok ( Attribute :: EndDate ( Date :: new_empty ( ) ) )
889
+ } else {
890
+ let date = val. as_ptr ( ) as * const CK_DATE ;
891
+ unsafe {
892
+ let year = String :: from_utf8_lossy ( Vec :: from ( ( * date) . year ) . as_slice ( ) )
893
+ . trim_end ( )
894
+ . to_string ( ) ;
895
+ let month = String :: from_utf8_lossy ( Vec :: from ( ( * date) . month ) . as_slice ( ) )
896
+ . trim_end ( )
897
+ . to_string ( ) ;
898
+ let day = String :: from_utf8_lossy ( Vec :: from ( ( * date) . day ) . as_slice ( ) )
899
+ . trim_end ( )
900
+ . to_string ( ) ;
901
+ Ok ( Attribute :: EndDate ( Date :: new_from_str_slice (
902
+ year. as_str ( ) ,
903
+ month. as_str ( ) ,
904
+ day. as_str ( ) ,
905
+ ) ?) )
906
+ }
903
907
}
904
908
}
905
909
AttributeType :: StartDate => {
906
- let date = val. as_ptr ( ) as * const CK_DATE ;
907
- unsafe {
908
- let year = String :: from_utf8_lossy ( Vec :: from ( ( * date) . year ) . as_slice ( ) )
909
- . trim_end ( )
910
- . to_string ( ) ;
911
- let month = String :: from_utf8_lossy ( Vec :: from ( ( * date) . month ) . as_slice ( ) )
912
- . trim_end ( )
913
- . to_string ( ) ;
914
- let day = String :: from_utf8_lossy ( Vec :: from ( ( * date) . day ) . as_slice ( ) )
915
- . trim_end ( )
916
- . to_string ( ) ;
917
- Ok ( Attribute :: StartDate ( Date :: new_from_str_slice (
918
- year. as_str ( ) ,
919
- month. as_str ( ) ,
920
- day. as_str ( ) ,
921
- ) ?) )
910
+ if val. is_empty ( ) {
911
+ Ok ( Attribute :: EndDate ( Date :: new_empty ( ) ) )
912
+ } else {
913
+ let date = val. as_ptr ( ) as * const CK_DATE ;
914
+ unsafe {
915
+ let year = String :: from_utf8_lossy ( Vec :: from ( ( * date) . year ) . as_slice ( ) )
916
+ . trim_end ( )
917
+ . to_string ( ) ;
918
+ let month = String :: from_utf8_lossy ( Vec :: from ( ( * date) . month ) . as_slice ( ) )
919
+ . trim_end ( )
920
+ . to_string ( ) ;
921
+ let day = String :: from_utf8_lossy ( Vec :: from ( ( * date) . day ) . as_slice ( ) )
922
+ . trim_end ( )
923
+ . to_string ( ) ;
924
+ Ok ( Attribute :: StartDate ( Date :: new_from_str_slice (
925
+ year. as_str ( ) ,
926
+ month. as_str ( ) ,
927
+ day. as_str ( ) ,
928
+ ) ?) )
929
+ }
922
930
}
923
931
}
924
932
}
0 commit comments