Contents

CVAttachmentKeyDefinitions

Marks a type as a collection of attachment keys for an attachment bearer.

Declaration

protocol CVAttachmentKeyDefinitions

Overview

The static properties of a type which implements this protocol provide definitions for the attachment keys. The static properties which have one of CVAttachmentKeyDefinitions.Key, CVAttachmentKeyDefinitions.KeyWithDefault or CVAttachmentKeyDefinitions.CompositeKey type are used by an attachment access provider to get and set attachment values.

For example, a custom attachment key for pixel buffers can be defined as:

extension CVPixelBufferAttachmentKeyDefinitions {
	// This extension makes the key available as a property of `pixelBuffer.attachments`.
	static var customAttachment: Key<ShouldPropagate, CustomAttachmentValue> {
		.init("com.myapp.customAttachmentKey")
	}
}

// This extension facilitates conversion between CustomAttachmentValue and CVAttachmentRawValue
extension CustomAttachmentValue: CVAttachmentValueRepresentable {
	static func makeFromRawAttachmentValue(_ repr: CVAttachmentRawValue) -> Self? {
		...
	}

	var rawAttachmentValueRepresentation: CVAttachmentRawValue {
		...
	}
}

Topics

Type Aliases

See Also

Protocols