---
title: DataProtocol
framework: foundation
role: symbol
role_heading: Protocol
path: foundation/dataprotocol
---

# DataProtocol

A protocol that provides consistent data access to the bytes underlying contiguous and noncontiguous data buffers.

## Declaration

```swift
protocol DataProtocol : RandomAccessCollection where Self.Element == UInt8, Self.SubSequence : DataProtocol
```

## Topics

### Accessing Backing Storage

- [regions](foundation/dataprotocol/regions-swift.property.md)
- [Regions](foundation/dataprotocol/regions-swift.associatedtype.md)

### Copying Underlying Bytes

- [copyBytes(to:)](foundation/dataprotocol/copybytes(to:)-52wps.md)
- [copyBytes(to:)](foundation/dataprotocol/copybytes(to:)-3mk27.md)
- [copyBytes(to:count:)](foundation/dataprotocol/copybytes(to:count:)-6krsm.md)
- [copyBytes(to:count:)](foundation/dataprotocol/copybytes(to:count:)-29t5.md)
- [copyBytes(to:from:)](foundation/dataprotocol/copybytes(to:from:)-1ol47.md)
- [copyBytes(to:from:)](foundation/dataprotocol/copybytes(to:from:)-1y839.md)

### Searching Within Data

- [firstRange(of:)](foundation/dataprotocol/firstrange(of:).md)
- [firstRange(of:in:)](foundation/dataprotocol/firstrange(of:in:).md)
- [lastRange(of:)](foundation/dataprotocol/lastrange(of:).md)
- [lastRange(of:in:)](foundation/dataprotocol/lastrange(of:in:).md)

## Relationships

### Inherits From

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sequence](swift/sequence.md)

### Inherited By

- [MutableDataProtocol](foundation/mutabledataprotocol.md)

### Conforming Types

- [Data](foundation/data.md)
- [NSData](foundation/nsdata.md)
- [NSMutableData](foundation/nsmutabledata.md)
- [NSPurgeableData](foundation/nspurgeabledata.md)

## See Also

### Binary Data

- [Data](foundation/data.md)
- [MutableDataProtocol](foundation/mutabledataprotocol.md)
- [ContiguousBytes](foundation/contiguousbytes.md)
