Fixes in response to review feedback.
This commit is contained in:
parent
6482f419b8
commit
1aff5b9198
|
|
@ -67,15 +67,17 @@ foreign_type_and_impl_send_sync! {
|
||||||
impl fmt::Display for Asn1GeneralizedTimeRef {
|
impl fmt::Display for Asn1GeneralizedTimeRef {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
unsafe {
|
unsafe {
|
||||||
match MemBio::new() {
|
let mem_bio = match MemBio::new() {
|
||||||
|
Err(_) => return f.write_str(""),
|
||||||
|
Ok(m) => m,
|
||||||
|
};
|
||||||
|
let print_result = cvt(ffi::ASN1_GENERALIZEDTIME_print(
|
||||||
|
mem_bio.as_ptr(),
|
||||||
|
self.as_ptr(),
|
||||||
|
));
|
||||||
|
match print_result {
|
||||||
Err(_) => f.write_str(""),
|
Err(_) => f.write_str(""),
|
||||||
Ok(mem_bio) => match cvt(ffi::ASN1_GENERALIZEDTIME_print(
|
Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())),
|
||||||
mem_bio.as_ptr(),
|
|
||||||
self.as_ptr(),
|
|
||||||
)) {
|
|
||||||
Err(_) => f.write_str(""),
|
|
||||||
Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,12 +213,14 @@ impl<'a> PartialOrd<Asn1Time> for &'a Asn1TimeRef {
|
||||||
impl fmt::Display for Asn1TimeRef {
|
impl fmt::Display for Asn1TimeRef {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
unsafe {
|
unsafe {
|
||||||
match MemBio::new() {
|
let mem_bio = match MemBio::new() {
|
||||||
|
Err(_) => return f.write_str("error"),
|
||||||
|
Ok(m) => m,
|
||||||
|
};
|
||||||
|
let print_result = cvt(ffi::ASN1_TIME_print(mem_bio.as_ptr(), self.as_ptr()));
|
||||||
|
match print_result {
|
||||||
Err(_) => f.write_str("error"),
|
Err(_) => f.write_str("error"),
|
||||||
Ok(mem_bio) => match cvt(ffi::ASN1_TIME_print(mem_bio.as_ptr(), self.as_ptr())) {
|
Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())),
|
||||||
Err(_) => f.write_str("error"),
|
|
||||||
Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,9 +301,7 @@ impl<T> fmt::Debug for PKey<T> {
|
||||||
Id::ED448 => "Ed448",
|
Id::ED448 => "Ed448",
|
||||||
_ => "unknown",
|
_ => "unknown",
|
||||||
};
|
};
|
||||||
fmt.debug_struct("public_key")
|
fmt.debug_struct("PKey").field("algorithm", &alg).finish()
|
||||||
.field("algorithm", &alg)
|
|
||||||
.finish()
|
|
||||||
// TODO: Print details for each specific type of key
|
// TODO: Print details for each specific type of key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1342,19 +1342,17 @@ impl GeneralNameRef {
|
||||||
impl fmt::Debug for GeneralNameRef {
|
impl fmt::Debug for GeneralNameRef {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if let Some(email) = self.email() {
|
if let Some(email) = self.email() {
|
||||||
return formatter.write_str(email);
|
formatter.write_str(email)
|
||||||
}
|
} else if let Some(dnsname) = self.dnsname() {
|
||||||
if let Some(dnsname) = self.dnsname() {
|
formatter.write_str(dnsname)
|
||||||
return formatter.write_str(dnsname);
|
} else if let Some(uri) = self.uri() {
|
||||||
}
|
formatter.write_str(uri)
|
||||||
if let Some(uri) = self.uri() {
|
} else if let Some(ipaddress) = self.ipaddress() {
|
||||||
return formatter.write_str(uri);
|
|
||||||
}
|
|
||||||
if let Some(ipaddress) = self.ipaddress() {
|
|
||||||
let result = String::from_utf8_lossy(ipaddress);
|
let result = String::from_utf8_lossy(ipaddress);
|
||||||
return formatter.write_str(&result);
|
formatter.write_str(&result)
|
||||||
|
} else {
|
||||||
|
formatter.write_str("(empty)")
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ fn test_debug() {
|
||||||
],
|
],
|
||||||
not_before: Aug 14 17:00:03 2016 GMT,
|
not_before: Aug 14 17:00:03 2016 GMT,
|
||||||
not_after: Aug 12 17:00:03 2026 GMT,
|
not_after: Aug 12 17:00:03 2026 GMT,
|
||||||
public_key: public_key {
|
public_key: PKey {
|
||||||
algorithm: "RSA",
|
algorithm: "RSA",
|
||||||
},
|
},
|
||||||
}"#;
|
}"#;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue