Struct elliptic_curve::PublicKey
source · [−]pub struct PublicKey<C> where
C: Curve + ProjectiveArithmetic, { /* private fields */ }
arithmetic
only.Expand description
Elliptic curve public keys.
This is a wrapper type for AffinePoint
which ensures an inner
non-identity point and provides a common place to handle encoding/decoding.
Parsing “SPKI” Keys
X.509 SubjectPublicKeyInfo
(SPKI) is a commonly used format for encoding
public keys, notably public keys corresponding to PKCS#8 private keys.
(especially ones generated by OpenSSL).
Keys in SPKI format are either binary (ASN.1 BER/DER), or PEM encoded (ASCII) and begin with the following:
-----BEGIN PUBLIC KEY-----
To decode an elliptic curve public key from SPKI, enable the pkcs8
feature of this crate (or the pkcs8
feature of a specific RustCrypto
elliptic curve crate) and use the
[elliptic_curve::pkcs8::DecodePublicKey
][pkcs8::DecodePublicKey
]
trait to parse it.
When the pem
feature of this crate (or a specific RustCrypto elliptic
curve crate) is enabled, a FromStr
impl is also available.
serde
support
When the optional serde
feature of this create is enabled, Serialize
and Deserialize
impls are provided for this type.
The serialization is binary-oriented and supports ASN.1 DER Subject Public Key Info (SPKI) as the encoding format.
For a more text-friendly encoding of public keys, use JwkEcKey
instead.
Implementations
sourceimpl<C> PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C> PublicKey<C> where
C: Curve + ProjectiveArithmetic,
sourcepub fn from_affine(point: AffinePoint<C>) -> Result<Self>
pub fn from_affine(point: AffinePoint<C>) -> Result<Self>
Convert an AffinePoint
into a PublicKey
sourcepub fn from_secret_scalar(scalar: &NonZeroScalar<C>) -> Self
pub fn from_secret_scalar(scalar: &NonZeroScalar<C>) -> Self
Compute a PublicKey
from a secret NonZeroScalar
value
(i.e. a secret key represented as a raw scalar value)
sourcepub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self> where
C: Curve,
FieldSize<C>: ModulusSize,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
pub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self> where
C: Curve,
FieldSize<C>: ModulusSize,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
Decode PublicKey
(compressed or uncompressed) from the
Elliptic-Curve-Point-to-Octet-String
encoding described in
SEC 1: Elliptic Curve Cryptography (Version 2.0) section
2.3.3 (page 10).
sourcepub fn as_affine(&self) -> &AffinePoint<C>
pub fn as_affine(&self) -> &AffinePoint<C>
Borrow the inner AffinePoint
from this PublicKey
.
In ECC, public keys are elliptic curve points.
sourcepub fn to_projective(&self) -> ProjectivePoint<C>
pub fn to_projective(&self) -> ProjectivePoint<C>
Convert this PublicKey
to a ProjectivePoint
for the given curve
sourcepub fn from_jwk(jwk: &JwkEcKey) -> Result<Self> where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
pub fn from_jwk(jwk: &JwkEcKey) -> Result<Self> where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.sourcepub fn from_jwk_str(jwk: &str) -> Result<Self> where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
pub fn from_jwk_str(jwk: &str) -> Result<Self> where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.Parse a string containing a JSON Web Key (JWK) into a PublicKey
.
sourcepub fn to_jwk(&self) -> JwkEcKey where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
pub fn to_jwk(&self) -> JwkEcKey where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.Serialize this public key as JwkEcKey
JSON Web Key (JWK).
sourcepub fn to_jwk_string(&self) -> String where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
pub fn to_jwk_string(&self) -> String where
C: Curve + JwkParameters,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.Serialize this public key as JSON Web Key (JWK) string.
Trait Implementations
sourceimpl<C> AsRef<<C as AffineArithmetic>::AffinePoint> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C> AsRef<<C as AffineArithmetic>::AffinePoint> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
sourcefn as_ref(&self) -> &AffinePoint<C>
fn as_ref(&self) -> &AffinePoint<C>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<C> DecodePublicKey for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate features pkcs8
and sec1
only.
impl<C> DecodePublicKey for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pkcs8
and sec1
only.fn from_public_key_der(bytes: &[u8]) -> Result<Self, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<Self, Error>
Deserialize object from ASN.1 DER-encoded [SubjectPublicKeyInfo
]
(binary format). Read more
fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
Deserialize PEM-encoded [SubjectPublicKeyInfo
]. Read more
sourceimpl<'de, C> Deserialize<'de> for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature serde
only.
impl<'de, C> Deserialize<'de> for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
serde
only.sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<C> EncodePublicKey for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate features alloc
and pkcs8
only.
impl<C> EncodePublicKey for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
alloc
and pkcs8
only.sourcefn to_public_key_der(&self) -> Result<Document>
fn to_public_key_der(&self) -> Result<Document>
Serialize a Document
containing a SPKI-encoded public key.
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
Serialize this public key as PEM-encoded SPKI with the given LineEnding
.
sourceimpl<C> From<&EphemeralSecret<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
Available on crate feature ecdh
only.
impl<C> From<&EphemeralSecret<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
ecdh
only.sourcefn from(ephemeral_secret: &EphemeralSecret<C>) -> Self
fn from(ephemeral_secret: &EphemeralSecret<C>) -> Self
Converts to this type from the input type.
sourceimpl<C> From<&PublicKey<C>> for EncodedPoint<C> where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> From<&PublicKey<C>> for EncodedPoint<C> where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.sourcefn from(public_key: &PublicKey<C>) -> EncodedPoint<C>
fn from(public_key: &PublicKey<C>) -> EncodedPoint<C>
Converts to this type from the input type.
sourceimpl<C> From<&PublicKey<C>> for JwkEcKey where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
impl<C> From<&PublicKey<C>> for JwkEcKey where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.sourceimpl<C> From<PublicKey<C>> for EncodedPoint<C> where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> From<PublicKey<C>> for EncodedPoint<C> where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.sourcefn from(public_key: PublicKey<C>) -> EncodedPoint<C>
fn from(public_key: PublicKey<C>) -> EncodedPoint<C>
Converts to this type from the input type.
sourceimpl<C> From<PublicKey<C>> for JwkEcKey where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
impl<C> From<PublicKey<C>> for JwkEcKey where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.sourceimpl<C> FromEncodedPoint<C> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> FromEncodedPoint<C> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.sourcefn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self>
fn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self>
Initialize PublicKey
from an EncodedPoint
sourceimpl<C> FromStr for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pem
only.
impl<C> FromStr for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
only.sourceimpl<C> Ord for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> Ord for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<C: PartialEq> PartialEq<PublicKey<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C: PartialEq> PartialEq<PublicKey<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
sourceimpl<C> PartialOrd<PublicKey<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> PartialOrd<PublicKey<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<C> Serialize for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature serde
only.
impl<C> Serialize for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
serde
only.sourceimpl<C> ToEncodedPoint<C> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature sec1
only.
impl<C> ToEncodedPoint<C> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
sec1
only.sourcefn to_encoded_point(&self, compress: bool) -> EncodedPoint<C>
fn to_encoded_point(&self, compress: bool) -> EncodedPoint<C>
Serialize this PublicKey
as a SEC1 EncodedPoint
, optionally applying
point compression
sourceimpl<C> ToString for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature pem
only.
impl<C> ToString for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pem
only.sourceimpl<C> TryFrom<&JwkEcKey> for PublicKey<C> where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
impl<C> TryFrom<&JwkEcKey> for PublicKey<C> where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.sourceimpl<C> TryFrom<JwkEcKey> for PublicKey<C> where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate feature jwk
only.
impl<C> TryFrom<JwkEcKey> for PublicKey<C> where
C: Curve + JwkParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
jwk
only.sourceimpl<C> TryFrom<SubjectPublicKeyInfo<'_>> for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Available on crate features pkcs8
and sec1
only.
impl<C> TryFrom<SubjectPublicKeyInfo<'_>> for PublicKey<C> where
C: Curve + AssociatedOid + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
pkcs8
and sec1
only.impl<C> Copy for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C: Eq> Eq for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C> StructuralEq for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
impl<C> StructuralPartialEq for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
Auto Trait Implementations
impl<C> RefUnwindSafe for PublicKey<C> where
<C as AffineArithmetic>::AffinePoint: RefUnwindSafe,
impl<C> Send for PublicKey<C>
impl<C> Sync for PublicKey<C>
impl<C> Unpin for PublicKey<C> where
<C as AffineArithmetic>::AffinePoint: Unpin,
impl<C> UnwindSafe for PublicKey<C> where
<C as AffineArithmetic>::AffinePoint: UnwindSafe,
Blanket Implementations
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore,
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore,
fn as_bits<O>(&self) -> &BitSlice<T, O> where
O: BitOrder,
fn as_bits<O>(&self) -> &BitSlice<T, O> where
O: BitOrder,
Views self
as an immutable bit-slice region with the O
ordering.
fn try_as_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
fn try_as_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
Attempts to view self
as an immutable bit-slice region with the O
ordering. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Causes self
to use its Binary
implementation when Debug
-formatted. Read more
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes self
to use its Octal
implementation when Debug
-formatted. Read more
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
impl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
Borrows self
and passes that borrow into the pipe function. Read more
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.deref()
into the pipe function.
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R>
view of a value. Read more
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target
of a value. Read more
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target
of a value. Read more
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap()
only in debug builds, and is erased in release builds.
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more