Skip to content

Commit 1da2ff4

Browse files
committed
add TODO comment for optimizing string validation
Signed-off-by: Facundo Tuesca <[email protected]>
1 parent 15e9abf commit 1da2ff4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/rust/src/declarative_asn1/types.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ impl Size {
134134
}
135135
}
136136

137+
// TODO: Once the minimum Python version is >= 3.10, use a `self_cell`
138+
// to store the owned PyString along with the dependent Asn1PrintableString
139+
// in order to avoid verifying the string twice (once during construction,
140+
// and again during serialization).
141+
// This is because for Python < 3.10 getting an Asn1PrintableString object
142+
// from a PyString requires calling `to_cow()`, which creates an intermediate
143+
// `Cow` object with a different lifetime from the PyString.
137144
#[derive(pyo3::FromPyObject)]
138145
#[pyo3::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.asn1")]
139146
pub struct PrintableString {
@@ -168,6 +175,13 @@ impl PrintableString {
168175
}
169176
}
170177

178+
// TODO: Once the minimum Python version is >= 3.10, use a `self_cell`
179+
// to store the owned PyString along with the dependent Asn1IA5String
180+
// in order to avoid verifying the string twice (once during construction,
181+
// and again during serialization).
182+
// This is because for Python < 3.10 getting an Asn1IA5String object
183+
// from a PyString requires calling `to_cow()`, which creates an intermediate
184+
// `Cow` object with a different lifetime from the PyString.
171185
#[derive(pyo3::FromPyObject)]
172186
#[pyo3::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.asn1")]
173187
pub struct IA5String {

0 commit comments

Comments
 (0)