startIndex
Always zero, which is the index of the first byte in a nonempty buffer.
var startIndex: UnsafeRawBufferPointer.Index { get }
Always zero, which is the index of the first byte in a nonempty buffer.
var startIndex: UnsafeRawBufferPointer.Index { get }
import Swift
@frozen struct UnsafeRawBufferPointer
A nonowning collection interface to the bytes in a region of memory.
typealias Index = Int
init(_ bytes: UnsafeRawBufferPointer)
Creates a new buffer over the same memory as the given buffer.
init<T>(_ buffer: UnsafeBufferPointer<T>) where T : ~Copyable
Creates a raw buffer over the contiguous bytes in the given typed buffer.
init<T>(_ buffer: UnsafeMutableBufferPointer<T>) where T : ~Copyable
Creates a raw buffer over the contiguous bytes in the given typed buffer.
init(_ bytes: UnsafeMutableRawBufferPointer)
Creates a new buffer over the same memory as the given buffer.
init(rebasing slice: Slice<UnsafeRawBufferPointer>)
Creates a raw buffer over the same memory as the given raw buffer slice, with the indices rebased to zero.
init(rebasing slice: Slice<UnsafeMutableRawBufferPointer>)
Creates a raw buffer over the same memory as the given raw buffer slice, with the indices rebased to zero.
init(start: UnsafeRawPointer?, count: Int)
Creates a buffer over the specified number of contiguous bytes starting at the given pointer.
var baseAddress: UnsafeRawPointer? { get }
A pointer to the first byte of the buffer.
var count: Int { get }
The number of bytes in the buffer.
var debugDescription: String { get }
A textual representation of the buffer, suitable for debugging.
var endIndex: UnsafeRawBufferPointer.Index { get }
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var indices: UnsafeRawBufferPointer.Indices { get }
subscript(bounds: Range<Int>) -> UnsafeRawBufferPointer.SubSequence { get }
Accesses the bytes in the specified memory region.
subscript(i: Int) -> UnsafeRawBufferPointer.Element { get }
Accesses the byte at the given offset in the memory region as a UInt8
value.
func assumingMemoryBound<T>(to: T.Type) -> UnsafeBufferPointer<T> where T : ~Copyable
Returns a typed buffer to the memory referenced by this buffer, assuming that the memory is already bound to the specified type.
@discardableResult func bindMemory<T>(to type: T.Type) -> UnsafeBufferPointer<T> where T : ~Copyable
Binds this buffer’s memory to the specified type and returns a typed buffer of the bound memory.
func deallocate()
Deallocates the memory block previously allocated at this buffer pointer’s base address.
func load<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T
Returns a new instance of the given type, read from the buffer pointer’s raw memory at the specified byte offset.
func loadUnaligned<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T
func loadUnaligned<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T where T : BitwiseCopyable
Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func makeIterator() -> UnsafeRawBufferPointer.Iterator
Returns an iterator over the bytes of this sequence.
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<UnsafeRawBufferPointer.Element>) throws -> R) rethrows -> R?
func withMemoryRebound<T, E, Result>(to type: T.Type, _ body: (UnsafeBufferPointer<T>) throws(E) -> Result) throws(E) -> Result where E : Error, T : ~Copyable, Result : ~Copyable
Executes the given closure while temporarily binding the buffer to instances of type T
.
@frozen struct Iterator
An iterator over the bytes viewed by a raw buffer pointer.
typealias Element = UInt8
typealias Indices = Range<Int>
typealias SubSequence = Slice<UnsafeRawBufferPointer>