---
title: CGDataConsumerPutBytesCallback
framework: coregraphics
role: symbol
role_heading: Type Alias
path: coregraphics/cgdataconsumerputbytescallback
---

# CGDataConsumerPutBytesCallback

Copies data from a Core Graphics-supplied buffer into a data consumer.

## Declaration

```swift
typealias CGDataConsumerPutBytesCallback = (UnsafeMutableRawPointer?, UnsafeRawPointer, Int) -> Int
```

## Parameters

- `info`: A generic pointer to private data shared among your callback functions. This is the pointer supplied to doc://com.apple.coregraphics/documentation/CoreGraphics/CGDataConsumer/init(info:cbks:).
- `buffer`: The buffer from which you copy the specified number of bytes.
- `count`: The number of bytes to copy.

## Return Value

Return Value The number of bytes copied. If no more data can be written to the consumer, you should return 0.

## Discussion

Discussion When Core Graphics is ready to send data to the consumer, your function is called. It should copy the specified number of bytes from buffer into some resource under your control—for example, a file. For information on how to associate your callback function with a data consumer, see init(info:cbks:) and CGDataConsumerCallbacks.

## See Also

### Creating Data Consumers

- [init(info:cbks:)](coregraphics/cgdataconsumer/init(info:cbks:).md)
- [init(url:)](coregraphics/cgdataconsumer/init(url:).md)
- [init(data:)](coregraphics/cgdataconsumer/init(data:).md)
- [CGDataConsumerCallbacks](coregraphics/cgdataconsumercallbacks.md)
- [CGDataConsumerReleaseInfoCallback](coregraphics/cgdataconsumerreleaseinfocallback.md)
