Trait rocket::mtls::x509::der_parser::asn1_rs::nom::lib::std::ops::Deref

1.0.0 · source ·
pub trait Deref {
    type Target: ?Sized;

    // Required method
    fn deref(&self) -> &Self::Target;
}
Available on crate feature mtls only.
Expand description

Used for immutable dereferencing operations, like *v.

In addition to being used for explicit dereferencing operations with the (unary) * operator in immutable contexts, Deref is also used implicitly by the compiler in many circumstances. This mechanism is called Deref coercion”. In mutable contexts, DerefMut is used and mutable deref coercion similarly occurs.

Warning: Deref coercion is a powerful language feature which has far-reaching implications for every type that implements Deref. The compiler will silently insert calls to Deref::deref. For this reason, one should be careful about implementing Deref and only do so when deref coercion is desirable. See below for advice on when this is typically desirable or undesirable.

Types that implement Deref or DerefMut are often called “smart pointers” and the mechanism of deref coercion has been specifically designed to facilitate the pointer-like behaviour that name suggests. Often, the purpose of a “smart pointer” type is to change the ownership semantics of a contained value (for example, Rc or Cow) or the storage semantics of a contained value (for example, Box).

§Deref coercion

If T implements Deref<Target = U>, and v is a value of type T, then:

  • In immutable contexts, *v (where T is neither a reference nor a raw pointer) is equivalent to *Deref::deref(&v).
  • Values of type &T are coerced to values of type &U
  • T implicitly implements all the methods of the type U which take the &self receiver.

For more details, visit the chapter in The Rust Programming Language as well as the reference sections on the dereference operator, method resolution, and type coercions.

§When to implement Deref or DerefMut

The same advice applies to both deref traits. In general, deref traits should be implemented if:

  1. a value of the type transparently behaves like a value of the target type;
  2. the implementation of the deref function is cheap; and
  3. users of the type will not be surprised by any deref coercion behaviour.

In general, deref traits should not be implemented if:

  1. the deref implementations could fail unexpectedly; or
  2. the type has methods that are likely to collide with methods on the target type; or
  3. committing to deref coercion as part of the public API is not desirable.

Note that there’s a large difference between implementing deref traits generically over many target types, and doing so only for specific target types.

Generic implementations, such as for Box<T> (which is generic over every type and dereferences to T) should be careful to provide few or no methods, since the target type is unknown and therefore every method could collide with one on the target type, causing confusion for users. impl<T> Box<T> has no methods (though several associated functions), partly for this reason.

Specific implementations, such as for String (whose Deref implementation has Target = str) can have many methods, since avoiding collision is much easier. String and str both have many methods, and String additionally behaves as if it has every method of str because of deref coercion. The implementing type may also be generic while the implementation is still specific in this sense; for example, Vec<T> dereferences to [T], so methods of T are not applicable.

Consider also that deref coercion means that deref traits are a much larger part of a type’s public API than any other trait as it is implicitly called by the compiler. Therefore, it is advisable to consider whether this is something you are comfortable supporting as a public API.

The AsRef and Borrow traits have very similar signatures to Deref. It may be desirable to implement either or both of these, whether in addition to or rather than deref traits. See their documentation for details.

§Fallibility

This trait’s method should never unexpectedly fail. Deref coercion means the compiler will often insert calls to Deref::deref implicitly. Failure during dereferencing can be extremely confusing when Deref is invoked implicitly. In the majority of uses it should be infallible, though it may be acceptable to panic if the type is misused through programmer error, for example.

However, infallibility is not enforced and therefore not guaranteed. As such, unsafe code should not rely on infallibility in general for soundness.

§Examples

A struct with a single field which is accessible by dereferencing the struct.

use std::ops::Deref;

struct DerefExample<T> {
    value: T
}

impl<T> Deref for DerefExample<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

let x = DerefExample { value: 'a' };
assert_eq!('a', *x);

Required Associated Types§

1.0.0 · source

type Target: ?Sized

The resulting type after dereferencing.

Required Methods§

1.0.0 · source

fn deref(&self) -> &Self::Target

Dereferences the value.

Implementors§

source§

impl Deref for InlinableString

source§

impl Deref for rustls::conn::connection::Connection

source§

impl Deref for rustls::quic::connection::Connection

source§

impl Deref for N

source§

impl Deref for rocket::form::name::Key

source§

impl Deref for rocket::form::name::Name

source§

impl Deref for NamedFile

§

impl Deref for ContentType

§

impl Deref for QMediaType

§

impl Deref for RawStrBuf

source§

impl Deref for Uncased<'_>

§

impl Deref for Path<'_>

§

impl Deref for Query<'_>

source§

impl Deref for CertificateDer<'_>

1.0.0 · source§

impl Deref for String

1.0.0 · source§

impl Deref for CString

1.0.0 · source§

impl Deref for OsString

1.0.0 · source§

impl Deref for PathBuf

source§

impl Deref for EcdsaSigningAlgorithm

source§

impl Deref for bytes::bytes::Bytes

source§

impl Deref for BytesMut

source§

impl Deref for Profile

source§

impl Deref for WakerRef<'_>

source§

impl Deref for InlineString

source§

impl Deref for AlgorithmIdentifier

source§

impl Deref for CertificateRevocationListDer<'_>

source§

impl Deref for CertificateSigningRequestDer<'_>

source§

impl Deref for Der<'_>

source§

impl Deref for EchConfigListBytes<'_>

source§

impl Deref for SubjectPublicKeyInfoDer<'_>

source§

impl Deref for rustls::client::client_conn::connection::ClientConnection

source§

impl Deref for UnbufferedClientConnection

source§

impl Deref for BorrowedPayload<'_>

source§

impl Deref for Tls12ClientSessionValue

source§

type Target = ClientSessionCommon

source§

impl Deref for Tls13ClientSessionValue

source§

type Target = ClientSessionCommon

source§

impl Deref for rustls::quic::connection::ClientConnection

source§

impl Deref for rustls::quic::connection::ServerConnection

source§

impl Deref for rustls::server::server_conn::connection::ServerConnection

source§

impl Deref for UnbufferedServerConnection

source§

impl Deref for i24

source§

impl Deref for i48

source§

impl Deref for u24

source§

impl Deref for u48

source§

impl Deref for Ranges

source§

impl Deref for s2n_quic_core::application::error::Error

source§

impl Deref for ServerName

source§

impl Deref for LocalAddress

source§

impl Deref for RemoteAddress

source§

impl Deref for AckDelayExponent

source§

impl Deref for ActiveConnectionIdLimit

source§

impl Deref for InitialMaxData

source§

impl Deref for InitialMaxStreamDataBidiLocal

source§

impl Deref for InitialMaxStreamDataBidiRemote

source§

impl Deref for InitialMaxStreamDataUni

source§

impl Deref for InitialMaxStreamsBidi

source§

impl Deref for InitialMaxStreamsUni

source§

impl Deref for InitialSourceConnectionId

source§

impl Deref for MaxAckDelay

source§

impl Deref for MaxDatagramFrameSize

source§

impl Deref for MaxIdleTimeout

source§

impl Deref for MaxUdpPayloadSize

source§

impl Deref for OriginalDestinationConnectionId

source§

impl Deref for RetrySourceConnectionId

source§

impl Deref for VarInt

source§

impl Deref for TempPath

source§

impl Deref for DocumentMut

source§

impl Deref for InternalString

source§

impl Deref for toml_edit::key::Key

source§

impl Deref for EnteredSpan

source§

impl Deref for BStr

source§

impl Deref for winnow::stream::Bytes

source§

impl Deref for Condition

source§

type Target = fn() -> bool

source§

impl<'a> Deref for Chunk<'a>

source§

impl<'a> Deref for RouteUri<'a>

source§

impl<'a> Deref for Certificate<'a>

source§

impl<'a> Deref for rocket::mtls::Name<'a>

source§

impl<'a> Deref for CRLDistributionPoints<'a>

source§

impl<'a> Deref for X509Certificate<'a>

1.36.0 · source§

impl<'a> Deref for IoSlice<'a>

1.36.0 · source§

impl<'a> Deref for IoSliceMut<'a>

source§

impl<'a> Deref for Curve25519SeedBin<'a>

source§

type Target = Buffer<'a, Curve25519SeedBinType>

source§

impl<'a> Deref for EcPrivateKeyBin<'a>

source§

type Target = Buffer<'a, EcPrivateKeyBinType>

source§

impl<'a> Deref for EcPrivateKeyRfc5915Der<'a>

source§

type Target = Buffer<'a, EcPrivateKeyRfc5915DerType>

source§

impl<'a> Deref for Pkcs8V1Der<'a>

source§

type Target = Buffer<'a, Pkcs8V1DerType>

source§

impl<'a> Deref for PublicKeyX509Der<'a>

source§

type Target = Buffer<'a, PublicKeyX509DerType>

source§

impl<'a> Deref for EncapsulationKeyBytes<'a>

source§

type Target = Buffer<'a, EncapsulationKeyBytesType>

source§

impl<'a> Deref for EndEntityCert<'a>

source§

type Target = Cert<'a>

source§

impl<'a> Deref for MaybeUninitSlice<'a>

source§

impl<'a, 'b> Deref for TransformBuf<'a, 'b>

source§

impl<'a, 'f> Deref for VaList<'a, 'f>
where 'f: 'a,

source§

impl<'a, R, G, T> Deref for MappedReentrantMutexGuard<'a, R, G, T>
where R: RawMutex + 'a, G: GetThreadId + 'a, T: 'a + ?Sized,

source§

impl<'a, R, G, T> Deref for ReentrantMutexGuard<'a, R, G, T>
where R: RawMutex + 'a, G: GetThreadId + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::mutex::MappedMutexGuard<'a, R, T>
where R: RawMutex + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::mutex::MutexGuard<'a, R, T>
where R: RawMutex + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::rwlock::MappedRwLockReadGuard<'a, R, T>
where R: RawRwLock + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::rwlock::MappedRwLockWriteGuard<'a, R, T>
where R: RawRwLock + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::rwlock::RwLockReadGuard<'a, R, T>
where R: RawRwLock + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for RwLockUpgradableReadGuard<'a, R, T>
where R: RawRwLockUpgrade + 'a, T: 'a + ?Sized,

source§

impl<'a, R, T> Deref for lock_api::rwlock::RwLockWriteGuard<'a, R, T>
where R: RawRwLock + 'a, T: 'a + ?Sized,

source§

impl<'a, T> Deref for SpinMutexGuard<'a, T>
where T: ?Sized,

source§

impl<'a, T> Deref for spin::mutex::MutexGuard<'a, T>
where T: ?Sized,

source§

impl<'a, T> Deref for tokio::sync::mutex::MappedMutexGuard<'a, T>
where T: ?Sized,

source§

impl<'a, T, C> Deref for sharded_slab::pool::Ref<'a, T, C>
where T: Clear + Default, C: Config,

source§

impl<'a, T, C> Deref for sharded_slab::pool::RefMut<'a, T, C>
where C: Config, T: Clear + Default,

source§

impl<'a, T, C> Deref for Entry<'a, T, C>
where C: Config,

source§

impl<'a, const L: usize> Deref for Encoder<'a, L>

source§

impl<'c> Deref for rocket::local::asynchronous::LocalRequest<'c>

source§

impl<'c> Deref for rocket::local::blocking::LocalRequest<'c>

source§

impl<'k> Deref for KeyMut<'k>

source§

impl<'rwlock, T> Deref for spin::rwlock::RwLockReadGuard<'rwlock, T>
where T: ?Sized,

source§

impl<'rwlock, T, R> Deref for RwLockUpgradableGuard<'rwlock, T, R>
where T: ?Sized,

source§

impl<'rwlock, T, R> Deref for spin::rwlock::RwLockWriteGuard<'rwlock, T, R>
where T: ?Sized,

source§

impl<'s> Deref for SockRef<'s>

source§

impl<'s, T> Deref for SliceVec<'s, T>

source§

impl<'v> Deref for rocket::form::Error<'v>

source§

impl<'v> Deref for Errors<'v>

source§

impl<A> Deref for TinyVec<A>
where A: Array,

source§

type Target = [<A as Array>::Item]

source§

impl<A> Deref for SmallVec<A>
where A: Array,

source§

type Target = [<A as Array>::Item]

source§

impl<A> Deref for ArrayVec<A>
where A: Array,

source§

type Target = [<A as Array>::Item]

1.0.0 · source§

impl<B> Deref for Cow<'_, B>
where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Borrow<B>,

source§

impl<B, T> Deref for zerocopy::Ref<B, [T]>
where B: ByteSlice, T: FromBytes,

source§

impl<B, T> Deref for zerocopy::Ref<B, T>
where B: ByteSlice, T: FromBytes,

source§

impl<D> Deref for Instruction<D>
where D: Dialect,

source§

impl<Data> Deref for rustls::quic::connection::ConnectionCommon<Data>

source§

impl<E> Deref for FormattedFields<E>
where E: ?Sized,

source§

impl<I> Deref for Pear<I>
where I: Input,

source§

impl<I> Deref for Located<I>

source§

impl<I> Deref for Partial<I>

source§

impl<I, S> Deref for Stateful<I, S>

source§

impl<K, V, S> Deref for AHashMap<K, V, S>

source§

type Target = HashMap<K, V, S>

source§

impl<L, R> Deref for Either<L, R>
where L: Deref, R: Deref<Target = <L as Deref>::Target>,

source§

type Target = <L as Deref>::Target

1.33.0 · source§

impl<Ptr> Deref for Pin<Ptr>
where Ptr: Deref,

source§

type Target = <Ptr as Deref>::Target

source§

impl<S> Deref for ImDocument<S>

1.0.0 · source§

impl<T> Deref for &T
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for &mut T
where T: ?Sized,

source§

impl<T> Deref for Capped<T>

source§

impl<T> Deref for Form<T>

source§

impl<T> Deref for Lenient<T>

source§

impl<T> Deref for Strict<T>

source§

impl<T> Deref for Json<T>

Available on crate feature json only.
source§

impl<T> Deref for SequenceOf<T>

source§

impl<T> Deref for SetOf<T>

source§

impl<T> Deref for ThinBox<T>
where T: ?Sized,

1.20.0 · source§

impl<T> Deref for ManuallyDrop<T>
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for core::cell::Ref<'_, T>
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for core::cell::RefMut<'_, T>
where T: ?Sized,

1.9.0 · source§

impl<T> Deref for AssertUnwindSafe<T>

source§

impl<T> Deref for std::sync::mutex::MappedMutexGuard<'_, T>
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for std::sync::mutex::MutexGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for ReentrantLockGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for std::sync::rwlock::MappedRwLockReadGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for std::sync::rwlock::MappedRwLockWriteGuard<'_, T>
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for std::sync::rwlock::RwLockReadGuard<'_, T>
where T: ?Sized,

1.0.0 · source§

impl<T> Deref for std::sync::rwlock::RwLockWriteGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for CachePadded<T>

source§

impl<T> Deref for ShardedLockReadGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for ShardedLockWriteGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for Tagged<T>

source§

impl<T> Deref for futures_util::lock::mutex::MutexGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for futures_util::lock::mutex::OwnedMutexGuard<T>
where T: ?Sized,

source§

impl<T> Deref for UnsafeRef<T>
where T: ?Sized,

source§

impl<T> Deref for Extent<T>

source§

impl<T> Deref for Metadata<'_, T>
where T: SmartDisplay + ?Sized,

Permit using Metadata as a smart pointer to the user-provided metadata.

source§

impl<T> Deref for rustls::conn::ConnectionCommon<T>

source§

impl<T> Deref for UnbufferedConnectionCommon<T>

source§

impl<T> Deref for tokio::sync::mutex::MutexGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for tokio::sync::mutex::OwnedMutexGuard<T>
where T: ?Sized,

source§

impl<T> Deref for OwnedRwLockWriteGuard<T>
where T: ?Sized,

source§

impl<T> Deref for tokio::sync::rwlock::read_guard::RwLockReadGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for tokio::sync::rwlock::write_guard::RwLockWriteGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for RwLockMappedWriteGuard<'_, T>
where T: ?Sized,

source§

impl<T> Deref for tokio::sync::watch::Ref<'_, T>

source§

impl<T> Deref for Unalign<T>
where T: Unaligned,

1.0.0 · source§

impl<T, A> Deref for rocket::mtls::x509::der_parser::asn1_rs::nom::lib::std::boxed::Box<T, A>
where A: Allocator, T: ?Sized,

1.12.0 · source§

impl<T, A> Deref for PeekMut<'_, T, A>
where T: Ord, A: Allocator,

1.0.0 · source§

impl<T, A> Deref for rocket::mtls::x509::der_parser::asn1_rs::nom::lib::std::vec::Vec<T, A>
where A: Allocator,

1.0.0 · source§

impl<T, A> Deref for Rc<T, A>
where A: Allocator, T: ?Sized,

source§

impl<T, A> Deref for UniqueRc<T, A>
where A: Allocator, T: ?Sized,

1.0.0 · source§

impl<T, A> Deref for Arc<T, A>
where A: Allocator, T: ?Sized,

source§

impl<T, A> Deref for allocator_api2::stable::boxed::Box<T, A>
where A: Allocator, T: ?Sized,

source§

impl<T, A> Deref for allocator_api2::stable::vec::Vec<T, A>
where A: Allocator,

source§

impl<T, B> Deref for Counter<T, B>

source§

impl<T, C> Deref for OwnedRef<T, C>
where T: Clear + Default, C: Config,

source§

impl<T, C> Deref for OwnedRefMut<T, C>
where T: Clear + Default, C: Config,

source§

impl<T, C> Deref for OwnedEntry<T, C>
where C: Config,

1.80.0 · source§

impl<T, F> Deref for LazyCell<T, F>
where F: FnOnce() -> T,

1.80.0 · source§

impl<T, F> Deref for LazyLock<T, F>
where F: FnOnce() -> T,

source§

impl<T, F> Deref for once_cell::sync::Lazy<T, F>
where F: FnOnce() -> T,

source§

impl<T, F> Deref for once_cell::unsync::Lazy<T, F>
where F: FnOnce() -> T,

source§

impl<T, F, R> Deref for spin::lazy::Lazy<T, F, R>
where F: FnOnce() -> T, R: RelaxStrategy,

source§

impl<T, F, S> Deref for ScopeGuard<T, F, S>
where F: FnOnce(T), S: Strategy,

source§

impl<T, N> Deref for GenericArray<T, N>
where N: ArrayLength<T>,

source§

impl<T, S> Deref for AHashSet<T, S>

source§

type Target = HashSet<T, S>

source§

impl<T, U> Deref for futures_util::lock::mutex::MappedMutexGuard<'_, T, U>
where T: ?Sized, U: ?Sized,

source§

impl<T, U> Deref for OwnedMappedMutexGuard<T, U>
where T: ?Sized, U: ?Sized,

source§

impl<T, U> Deref for OwnedRwLockReadGuard<T, U>
where T: ?Sized, U: ?Sized,

source§

impl<T, U> Deref for OwnedRwLockMappedWriteGuard<T, U>
where T: ?Sized, U: ?Sized,

source§

impl<T, const COMPACT: bool> Deref for MsgPack<T, COMPACT>

Available on crate feature msgpack only.
source§

impl<T: Send + Sync + 'static> Deref for State<T>

source§

impl<Z> Deref for Zeroizing<Z>
where Z: Zeroize,

source§

impl<const L: usize> Deref for Storage<L>

source§

impl<const SIZE: usize> Deref for WriteBuffer<SIZE>