<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveByteStreamProtocol",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Apple Archive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B18ByteStreamProtocolP"
  },
  "title" : "ArchiveByteStreamProtocol"
}
-->

# ArchiveByteStreamProtocol

A set of methods that defines the interface for using an archive stream that reads from and writes to buffers.

```
protocol ArchiveByteStreamProtocol
```

## Topics

### Reading and Writing Data

[`func read(into: UnsafeMutableRawBufferPointer) throws -> Int`](/documentation/AppleArchive/ArchiveByteStreamProtocol/read(into:))

Reads data to the specified buffer, not exceeding the buffer’s previously allocated size.

[`func read(into: UnsafeMutableRawBufferPointer, atOffset: Int64) throws -> Int`](/documentation/AppleArchive/ArchiveByteStreamProtocol/read(into:atOffset:))

Reads data at the supplied offset to the specified buffer, not exceeding the buffer’s previously allocated size.

[`func write(from: UnsafeRawBufferPointer) throws -> Int`](/documentation/AppleArchive/ArchiveByteStreamProtocol/write(from:))

Writes data from the specified buffer, not exceeding the buffer’s allocated size.

[`func write(from: UnsafeRawBufferPointer, atOffset: Int64) throws -> Int`](/documentation/AppleArchive/ArchiveByteStreamProtocol/write(from:atOffset:))

Writes data at the supplied offset from the specified buffer, not exceeding the buffer’s allocated size.

### Using Archive Byte Streams

[`func seek(toOffset: Int64, relativeTo: FileDescriptor.SeekOrigin) throws -> Int64`](/documentation/AppleArchive/ArchiveByteStreamProtocol/seek(toOffset:relativeTo:))

Updates the internal stream position to the specified offset relative to the specified origin.

[`func cancel()`](/documentation/AppleArchive/ArchiveByteStreamProtocol/cancel())

Cancels stream operations.

[`func close() throws`](/documentation/AppleArchive/ArchiveByteStreamProtocol/close())

Closes the stream and releases associated resources.

## Relationships

### Conforming Types

[`ArchiveByteStream`](/documentation/AppleArchive/ArchiveByteStream)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)