MutableManagedByteBuffer
public protocol MutableManagedByteBuffer : ManagedByteBuffer
-
Declaration
Swift
@discardableResult func withBufferAs<T, V>(type: T.Type, _ body: (UnsafeMutablePointer<T>, Int, inout Int) throws -> V) rethrows -> V
-
Declaration
Swift
@discardableResult func withBufferAs<T, V>(type: T.Type, _ body: (UnsafeMutableBufferPointer<T>, inout Int) throws -> V) rethrows -> V
-
Declaration
Swift
@discardableResult func withBytes<V>(_ body: (BytePointer, Int, inout Int) throws -> V) rethrows -> V
-
Executes the given closure with an UnsafeMutableBufferPointer representing the buffer.
Throws
Any error thrown by the closure.Declaration
Swift
@discardableResult func withBytes<V>(_ body: (UnsafeMutableBufferPointer<UInt8>, inout Int) throws -> V) rethrows -> V
Parameters
body
The closure which takes two parameters:
- The instance of UnsafeMutableBufferPointer
- The count of the valid bytes in the buffer passed by reference.
Return Value
The value returned by the closure.
-
Relocates a block of bytes to the beginning of the buffer region. The number of bytes relocated will be from the given index to the end of the buffer.
Declaration
Swift
func relocateToFront(start idx: Int) -> Int
Parameters
idx
the index of the first byte of the block of bytes to move to the beginning of the buffer.
Return Value
The number of bytes moved.
-
Relocates a block of bytes to the beginning of the buffer region.
Declaration
Swift
func relocateToFront(start idx: Int, count cc: Int)
Parameters
idx
The index of the first byte of the block of bytes to move to the beginning of the buffer.
cc
The number of bytes.
-
Declaration
Swift
@discardableResult func append<S>(contentsOf: S) -> Int where S : Sequence, S.Element == UInt8
-
Declaration
Swift
@discardableResult func append(byte: UInt8) -> Int?