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

Method cmp

crates/stdlib/src/openssl/cert.rs:109–134  ·  view source on GitHub ↗
(
            zelf: &Py<Self>,
            other: &PyObject,
            op: PyComparisonOp,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

107
108 impl Comparable for PySSLCertificate {
109 fn cmp(
110 zelf: &Py<Self>,
111 other: &PyObject,
112 op: PyComparisonOp,
113 vm: &VirtualMachine,
114 ) -> PyResult<PyComparisonValue> {
115 let other = class_or_notimplemented!(Self, other);
116
117 // Only support equality comparison
118 if !matches!(op, PyComparisonOp::Eq | PyComparisonOp::Ne) {
119 return Ok(PyComparisonValue::NotImplemented);
120 }
121
122 // Compare DER encodings
123 let self_der = zelf
124 .cert
125 .to_der()
126 .map_err(|e| convert_openssl_error(vm, e))?;
127 let other_der = other
128 .cert
129 .to_der()
130 .map_err(|e| convert_openssl_error(vm, e))?;
131
132 let eq = self_der == other_der;
133 Ok(op.eval_ord(eq.cmp(&true)).into())
134 }
135 }
136
137 impl Hashable for PySSLCertificate {

Callers

nothing calls this directly

Calls 2

convert_openssl_errorFunction · 0.85
eval_ordMethod · 0.80

Tested by

no test coverage detected