Skip to main content

vstd_extra/external/
bytemuck.rs

1// SPDX-License-Identifier: MPL-2.0
2//! Trusted contract for bytemuck 1.25.2's `bytes_of`.
3use vstd::prelude::*;
4
5verus! {
6
7#[verifier::external_trait_specification]
8pub unsafe trait ExNoUninit: Sized + Copy + 'static {
9    type ExternalTraitSpecificationFor: ::bytemuck::NoUninit;
10}
11
12/// The initialized object representation of a NoUninit value.
13pub uninterp spec fn object_bytes<T: ::bytemuck::NoUninit>(value: T) -> Seq<u8>;
14
15pub assume_specification<T: ::bytemuck::NoUninit>[ ::bytemuck::bytes_of::<T> ](value: &T) -> (bytes:
16    &[u8])
17    ensures
18        bytes@ == object_bytes(*value),
19        bytes@.len() == vstd::layout::size_of::<T>(),
20    opens_invariants none
21    no_unwind
22;
23
24} // verus!