Trait shadow_pod::Pod

source ·
pub unsafe trait Pod: Copy + 'static { }
Expand description

Marker trait that the given type is Plain Old Data; i.e. that it is safe to interpret any pattern of bits as a value of this type.

This is notably not true for many Rust types. e.g. interpreting the integer value 2 as a rust bool is undefined behavior.

We require Copy to also rule out anything that implements Drop.

References are inherently non-Pod, so we can require a ’static lifetime.

This is very similar in concept to bytemuck::AnyBitPattern. However, unlike AnyBitPattern, this trait does not say anything about how the type can be safely shared. e.g. while bytemuck::AnyBitPattern disallows pointer types, Pod does not.

§Safety

  • Any pattern of bits must be a valid value of the given type.
  • The type must not contain an UnsafeCell, or any other structure that contains an UnsafeCell (for example Cell). Otherwise the following code would have UB:
    let x = Cell::new(0);
    let y = as_u8_slice(&x);
    x.set(1);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Pod for i8

source§

impl Pod for i16

source§

impl Pod for i32

source§

impl Pod for i64

source§

impl Pod for isize

source§

impl Pod for u8

source§

impl Pod for u16

source§

impl Pod for u32

source§

impl Pod for u64

source§

impl Pod for usize

source§

impl Pod for in6_addr

source§

impl Pod for termios2

source§

impl Pod for sem_t

source§

impl Pod for msqid_ds

source§

impl Pod for sigset_t

source§

impl Pod for sysinfo

source§

impl Pod for clone_args

source§

impl Pod for max_align_t

source§

impl Pod for statvfs

source§

impl Pod for _libc_fpstate

source§

impl Pod for _libc_fpxreg

source§

impl Pod for _libc_xmmreg

source§

impl Pod for flock64

source§

impl Pod for flock

source§

impl Pod for ipc_perm

source§

impl Pod for mcontext_t

source§

impl Pod for pthread_attr_t

source§

impl Pod for shmid_ds

source§

impl Pod for sigaction

source§

impl Pod for siginfo_t

source§

impl Pod for stack_t

source§

impl Pod for stat64

source§

impl Pod for stat

source§

impl Pod for statfs64

source§

impl Pod for statfs

source§

impl Pod for statvfs64

source§

impl Pod for ucontext_t

source§

impl Pod for user

source§

impl Pod for user_fpregs_struct

source§

impl Pod for user_regs_struct

source§

impl Pod for Elf32_Chdr

source§

impl Pod for Elf64_Chdr

source§

impl Pod for __exit_status

source§

impl Pod for __timeval

source§

impl Pod for aiocb

source§

impl Pod for cmsghdr

source§

impl Pod for glob64_t

source§

impl Pod for mallinfo

source§

impl Pod for msghdr

source§

impl Pod for nl_mmap_hdr

source§

impl Pod for nl_mmap_req

source§

impl Pod for nl_pktinfo

source§

impl Pod for ntptimeval

source§

impl Pod for regex_t

source§

impl Pod for rtentry

source§

impl Pod for statx

source§

impl Pod for statx_timestamp

source§

impl Pod for termios

source§

impl Pod for timex

source§

impl Pod for utmpx

source§

impl Pod for Elf32_Ehdr

source§

impl Pod for Elf32_Phdr

source§

impl Pod for Elf32_Shdr

source§

impl Pod for Elf32_Sym

source§

impl Pod for Elf64_Ehdr

source§

impl Pod for Elf64_Phdr

source§

impl Pod for Elf64_Shdr

source§

impl Pod for Elf64_Sym

source§

impl Pod for __c_anonymous_sockaddr_can_j1939

source§

impl Pod for __c_anonymous_sockaddr_can_tp

source§

impl Pod for arpd_request

source§

impl Pod for can_filter

source§

impl Pod for can_frame

source§

impl Pod for canfd_frame

source§

impl Pod for cpu_set_t

source§

impl Pod for dirent64

source§

impl Pod for dirent

source§

impl Pod for dl_phdr_info

source§

impl Pod for dqblk

source§

impl Pod for fanotify_event_metadata

source§

impl Pod for fanotify_response

source§

impl Pod for ff_condition_effect

source§

impl Pod for ff_constant_effect

source§

impl Pod for ff_effect

source§

impl Pod for ff_envelope

source§

impl Pod for ff_periodic_effect

source§

impl Pod for ff_ramp_effect

source§

impl Pod for ff_replay

source§

impl Pod for ff_rumble_effect

source§

impl Pod for ff_trigger

source§

impl Pod for fsid_t

source§

impl Pod for genlmsghdr

source§

impl Pod for glob_t

source§

impl Pod for if_nameindex

source§

impl Pod for in6_pktinfo

source§

impl Pod for inotify_event

source§

impl Pod for input_absinfo

source§

impl Pod for input_event

source§

impl Pod for input_id

source§

impl Pod for input_keymap_entry

source§

impl Pod for input_mask

source§

impl Pod for itimerspec

source§

impl Pod for mntent

source§

impl Pod for mq_attr

source§

impl Pod for msginfo

source§

impl Pod for nlattr

source§

impl Pod for nlmsgerr

source§

impl Pod for nlmsghdr

source§

impl Pod for packet_mreq

source§

impl Pod for passwd

source§

impl Pod for posix_spawn_file_actions_t

source§

impl Pod for posix_spawnattr_t

source§

impl Pod for pthread_cond_t

source§

impl Pod for pthread_condattr_t

source§

impl Pod for pthread_mutex_t

source§

impl Pod for pthread_mutexattr_t

source§

impl Pod for pthread_rwlock_t

source§

impl Pod for pthread_rwlockattr_t

source§

impl Pod for regmatch_t

source§

impl Pod for rlimit64

source§

impl Pod for sembuf

source§

impl Pod for signalfd_siginfo

source§

impl Pod for sock_extended_err

source§

impl Pod for sockaddr_alg

source§

impl Pod for sockaddr_can

source§

impl Pod for sockaddr_nl

source§

impl Pod for sockaddr_vm

source§

impl Pod for spwd

source§

impl Pod for ucred

source§

impl Pod for uinput_abs_setup

source§

impl Pod for uinput_ff_erase

source§

impl Pod for uinput_ff_upload

source§

impl Pod for uinput_setup

source§

impl Pod for uinput_user_dev

source§

impl Pod for Dl_info

source§

impl Pod for addrinfo

source§

impl Pod for arphdr

source§

impl Pod for arpreq

source§

impl Pod for arpreq_old

source§

impl Pod for epoll_event

source§

impl Pod for fd_set

source§

impl Pod for ifaddrs

source§

impl Pod for in6_rtmsg

source§

impl Pod for in_addr

source§

impl Pod for in_pktinfo

source§

impl Pod for ip_mreq

source§

impl Pod for ip_mreq_source

source§

impl Pod for ip_mreqn

source§

impl Pod for lconv

source§

impl Pod for mmsghdr

source§

impl Pod for sched_param

source§

impl Pod for sigevent

source§

impl Pod for sockaddr

source§

impl Pod for sockaddr_in6

source§

impl Pod for sockaddr_in

source§

impl Pod for sockaddr_ll

source§

impl Pod for sockaddr_storage

source§

impl Pod for sockaddr_un

source§

impl Pod for tm

source§

impl Pod for utsname

source§

impl Pod for group

source§

impl Pod for hostent

source§

impl Pod for iovec

source§

impl Pod for ipv6_mreq

source§

impl Pod for itimerval

source§

impl Pod for linger

source§

impl Pod for pollfd

source§

impl Pod for protoent

source§

impl Pod for rlimit

source§

impl Pod for rusage

source§

impl Pod for servent

source§

impl Pod for sigval

source§

impl Pod for timespec

source§

impl Pod for timeval

source§

impl Pod for tms

source§

impl Pod for utimbuf

source§

impl Pod for winsize

source§

impl<T> Pod for MaybeUninit<T>
where T: Pod,

source§

impl<T, const N: usize> Pod for [T; N]
where T: Pod,

Implementors§