Skip to main content

Limits

Trait Limits 

Source
pub trait Limits: Copy {
    // Required method
    fn supports_hash(self, h: TpmiAlgHash) -> bool;

    // Provided method
    fn max_digest_size(self) -> usize { ... }
}
Expand description

Allows an implementation to restrict which values it can Marshal and Unmarshal.

This trait enables different implementations to share the same core type definitions while selectively supporting only a subset of variants. This selection can be enforced either at compile time or at runtime.

This approach is important for two main reasons:

  1. ABI Stability: It avoids the many compile-time #defines found in C implementations. Those defines often alter structure layouts, leading to API and ABI incompatibilities between libraries compiled with different options.

  2. Code Size: Restricting which algorithms and types the marshaling code must support can significantly reduce the final binary size, which is critical for constrained environments.

Required Methods§

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§