Cotton code
24 lines · 956 B · SwiftRaw
// Where picked bytes are kept: the store a photo or file column's reference// is answered by, in the environment.import CottonValuesimport SwiftUI/// Where picked bytes are kept, and where a kept reference can be read back.public protocol AttachmentStore: Sendable {    /// Keeps the file at `url` and answers its reference for a `type` column    /// (`.photo` or `.file`).    func store(fileAt url: URL, name: String?, for type: ColumnType) async throws -> AttachmentValue    /// A local file holding `ref`'s bytes, when this device has them.    func localURL(for ref: String) async -> URL?    /// Explicit single-file fetch, never called by an editor thumbnail.    func ensure(for ref: String) async throws -> URL?}extension AttachmentStore {    public func ensure(for ref: String) async throws -> URL? { await localURL(for: ref) }}extension EnvironmentValues {    @Entry public var attachmentStore: (any AttachmentStore)? = nil}