pub struct GetterImpl<S, A, G: Getter<S, A>>(pub G, _);Expand description
A wrapper of the Getter optic implementations, encapsulating a total getter function.
GetterImpl provides a way to define total getters - optics that retrieve
a value of type A from a source of type S.
This struct is particularly useful in scenarios where you need to compose or reuse getter logic
that always succeeds.
§Note
This struct is not intended to be created by users directly, but it implements a From<Getter<S,A>> so that implementors of new optic types can wrap their concrete implementation of a Getter optic.
§Type Parameters
S: The source type from which the value is to be retrieved.A: The target type of the value to be retrieved.
§See Also
Gettertrait for defining custom partial getters.- [
mapped_getter] function for creatingGetterImplinstances from mapping functions.
Tuple Fields§
§0: GImplementations§
Source§impl<S, I, G1: Getter<S, I>> GetterImpl<S, I, G1>
impl<S, I, G1: Getter<S, I>> GetterImpl<S, I, G1>
Sourcepub fn compose_with_partial_getter<A, PG2: PartialGetter<I, A>>(
self,
other: PartialGetterImpl<I, A, PG2>,
) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = PG2::GetterError>>
pub fn compose_with_partial_getter<A, PG2: PartialGetter<I, A>>( self, other: PartialGetterImpl<I, A, PG2>, ) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = PG2::GetterError>>
Composes this GetterImpl<S,I> with a PartialGetter<I,A>, resulting in a new PartialGetter<S, A>
that focuses through both optics sequentially.
The resulting PartialGetterImpl will attempt to extract a value by first applying self and then
other. If the second optic fails to focus, the composition will fail to focus.
§Type Parameters
A: The target type of the composed optic.PG2: The type of the partial getter to compose with.
§Parameters
other: The partial getter to compose with.
§Returns
A new PartialGetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_getter<A, G2: Getter<I, A>>(
self,
other: GetterImpl<I, A, G2>,
) -> GetterImpl<S, A, impl Getter<S, A>>
pub fn compose_with_getter<A, G2: Getter<I, A>>( self, other: GetterImpl<I, A, G2>, ) -> GetterImpl<S, A, impl Getter<S, A>>
Composes this GetterImpl<S,I> with a GetterImpl<I,A>, resulting in a new GetterImpl<S, A>
that focuses through both optics sequentially.
The resulting GetterImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed optic.G2: The type of the partial getter to compose with.
§Parameters
other: The getter to compose with.
§Returns
A new GetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_setter<A, S2: Setter<I, A>>(
self,
other: SetterImpl<I, A, S2>,
) -> SetterImpl<S, A, impl Setter<S, A>>where
G1: Setter<S, I>,
pub fn compose_with_setter<A, S2: Setter<I, A>>(
self,
other: SetterImpl<I, A, S2>,
) -> SetterImpl<S, A, impl Setter<S, A>>where
G1: Setter<S, I>,
Composes this GetterImpl<S,I> with a Setter<I,A>, resulting in a new Setter<S, A>
that focuses through both optics sequentially.
The resulting SetterImpl will attempt to set a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed optic.S2: The type of the setter to compose with.
§Parameters
other: The setter to compose with.
§Returns
A new SetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_prism<A, P2: Prism<I, A>>(
self,
other: PrismImpl<I, A, P2>,
) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = P2::GetterError>>
pub fn compose_with_prism<A, P2: Prism<I, A>>( self, other: PrismImpl<I, A, P2>, ) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = P2::GetterError>>
Composes this GetterImpl<S,I> with a Prism<I,A>, resulting in a new PartialGetterImpl<S, A>
that focuses through both optics sequentially.
The resulting PartialGetterImpl will attempt to extract a value by first applying self and then
other. If the prism fails to focus, the composition will fail.
§Type Parameters
A: The target type of the composed prism.P2: The type of the second prism to compose with.
§Parameters
other: The second prism to compose with.
§Returns
A new PartialGetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_lens<A, L2: Lens<I, A>>(
self,
other: LensImpl<I, A, L2>,
) -> GetterImpl<S, A, impl Getter<S, A>>
pub fn compose_with_lens<A, L2: Lens<I, A>>( self, other: LensImpl<I, A, L2>, ) -> GetterImpl<S, A, impl Getter<S, A>>
Composes this GetterImpl<S,I> with a LensImpl<I,A>, resulting in a new GetterImpl<S, A>
that focuses through both optics sequentially.
The resulting GetterImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed lens.L2: The type of the lens to compose with.
§Parameters
other: The lens to compose with.
§Returns
A new GetterImpl that represents the composition of self and other
Sourcepub fn compose_with_fallible_iso<A, FI2: FallibleIso<I, A>>(
self,
other: FallibleIsoImpl<I, A, FI2>,
) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = FI2::GetterError>>
pub fn compose_with_fallible_iso<A, FI2: FallibleIso<I, A>>( self, other: FallibleIsoImpl<I, A, FI2>, ) -> PartialGetterImpl<S, A, impl PartialGetter<S, A, GetterError = FI2::GetterError>>
Composes this GetterImpl<S,I> with a FallibleIso<I,A>, resulting in a new PartialGetterImpl<S, A>
that focuses through both prisms sequentially.
The resulting PartialGetterImpl will attempt to extract a value by first applying self and then
other. If the fallible iso fails to focus, the composition will fail to focus.
§Type Parameters
A: The target type of the composed prism.FI2: The type of the fallible iso to compose with.
§Parameters
other: The fallible iso to compose with.
§Returns
A new PartialGetterImpl that represents the composition of self and other.
Sourcepub fn compose_with_iso<A, ISO2: Iso<I, A>>(
self,
other: IsoImpl<I, A, ISO2>,
) -> GetterImpl<S, A, impl Getter<S, A>>
pub fn compose_with_iso<A, ISO2: Iso<I, A>>( self, other: IsoImpl<I, A, ISO2>, ) -> GetterImpl<S, A, impl Getter<S, A>>
Composes this GetterImpl<S,I> with an IsoImpl<I,A>, resulting in a new GetterImpl<S, A>
that focuses through both optics sequentially.
The resulting GetterImpl will extract a value by first applying self and then
other.
§Type Parameters
A: The target type of the composed lens.ISO2: The type of the lens to compose with.
§Parameters
other: The iso to compose with.
§Returns
A new GetterImpl that represents the composition of self and other
Trait Implementations§
Source§impl<S, A, G: Getter<S, A>> From<G> for GetterImpl<S, A, G>
impl<S, A, G: Getter<S, A>> From<G> for GetterImpl<S, A, G>
Source§impl<S, A, G: Getter<S, A>> HasGetter<S, A> for GetterImpl<S, A, G>
impl<S, A, G: Getter<S, A>> HasGetter<S, A> for GetterImpl<S, A, G>
Source§type GetterError = Infallible
type GetterError = Infallible
Infallible for infallible optics.