Aliases for pw::span
of bytes.
Typedefs | |
using | pw::ByteSpan = span< std::byte > |
using | pw::ConstByteSpan = span< const std::byte > |
Functions | |
template<typename T > | |
span< const std::byte, sizeof(T)> | pw::ObjectAsBytes (const T &obj) |
template<typename T > | |
span< std::byte, sizeof(T)> | pw::ObjectAsWritableBytes (T &obj) |
span< const std::byte, sizeof(T)> pw::ObjectAsBytes | ( | const T & | obj | ) |
Gets a read-only pw::span<const std::byte>
(ConstByteSpan
) view of an object.
This function is only available for types where it always safe to rely on the underlying bytes of the object, i.e. serializable objects designed to be sent over the wire. It cannot be used with, for example, types that include padding bytes, since those are indeterminate and may leak information.
For types that do not meet these criteria, it is still possible to represent them as bytes using pw::as_bytes
, albeit in a manner that is unsafe for serialization.
The returned span has a static extent.
span< std::byte, sizeof(T)> pw::ObjectAsWritableBytes | ( | T & | obj | ) |
Gets a writable pw::span<std::byte>
(ByteSpan
) view of an object.
This function is only available for types where it always safe to rely on the underlying bytes of the object, i.e. serializable objects designed to be sent over the wire. It cannot be used with, for example, types that include padding bytes, since those are indeterminate and may leak information.
For types that do not meet these criteria, it is still possible to represent them as bytes using pw::as_writable_bytes
, albeit in a manner that is unsafe for serialization.
The returned span has a static extent.