StructLayout
public struct StructLayout
A StructLayout
encapsulates information about the layout of a StructType
.
-
Returns the total size of the struct in bytes.
If the structure is packed, this returns a value that is effectively the sum of the sizes of its fields. If the structure is not packed, this returns the value of the sum of the sizes of its fields plus any platform-dictated padding.
Declaration
Swift
public let size: Size
-
Returns the alignment of the struct in bytes.
The alignment value is effectively the maximum of the alignment of each of its member values. This value will never be zero, as even an empty structure has an alignment of one byte.
Declaration
Swift
public let alignment: Alignment
-
Returns true if the structure type includes padding between elements.
Declaration
Swift
public let isPadded: Bool
-
Returns the number of elements of this structure type.
Declaration
Swift
public let elementCount: Int
-
Returns the offsets of each member from the start of the of the struct in bytes.
Declaration
Swift
public let memberOffsets: [Size]
-
Given a valid byte offset into the structure, returns the structure index that contains it.
Declaration
Swift
public func index(of offset: Size) -> Int