pub trait FallibleIso<S, A>:
HasGetter<S, A>
+ HasSetter<S, A>
+ HasReverseGet<S, A> { }Expand description
A FallibleIso defines a reversible, but potentially failing conversion between two types.
It provides:
try_getto convert a value of typeSto typeA, possibly failing with an error of typeGetterErrorsetto change the value the optic operates ontry_reverse_getto convert a value of typeAto typeS, possibly failing with an error of typeReverseError
This is useful when working with a data structure that can be represented in two different ways,
but conversion between the two types might fail, such as a String and an IpAddress
Type Arguments
S: The data type the optic operates onA: The data type the optic focuses on
§Note
This is a marker trait that is blanket implemented for all structs that satisfy the requirements.
§See Also
- [
Iso] — a variant ofFallibleIsowhere the mapping cannot fail. FallibleIsoImpl— the wrapper of opaque struct that implement theFallibleIsotrait