MCPcopy Index your code
hub / github.com/RustPython/RustPython / repr_str

Method repr_str

crates/stdlib/src/openssl/cert.rs:146–165  ·  view source on GitHub ↗
(zelf: &Py<Self>, _vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

144
145 impl Representable for PySSLCertificate {
146 fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
147 // Build subject string like "CN=localhost, O=Python"
148 let subject = zelf.cert.subject_name();
149 let mut parts: Vec<String> = Vec::new();
150 for entry in subject.entries() {
151 // Use short name (SN) if available, otherwise use OID
152 let name = match entry.object().nid().short_name() {
153 Ok(sn) => sn.to_string(),
154 Err(_) => obj2txt(entry.object(), true).unwrap_or_default(),
155 };
156 if let Ok(value) = entry.data().as_utf8() {
157 parts.push(format!("{}={}", name, value));
158 }
159 }
160 if parts.is_empty() {
161 Ok("<Certificate>".to_string())
162 } else {
163 Ok(format!("<Certificate '{}'>", parts.join(", ")))
164 }
165 }
166 }
167
168 fn name_to_py(vm: &VirtualMachine, name: &x509::X509NameRef) -> PyResult {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
obj2txtFunction · 0.85
to_stringMethod · 0.80
dataMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected