Cotton code
54 lines · 1.9 KB · SwiftRaw
// What a phone keeps — the three methods over the keep-rule tools// (`crates/cotton-ffi/src/phone/keep_rules.rs`): `keep.rules` answers// `list_keep_rules`, `keep.set` and `keep.clear` write through// `set_keep_rule` and `clear_keep_rule`. A request that names no device is// THIS device's.import Foundationextension CottonMethod {    /// `{device?}` → `{device, phone, narrowing, rules: [{kind, target, rule,    /// default, name, words, says, narrows}], choices: [{rule, words, offered, note}]}`.    public static let keepRules = "keep.rules"    /// `{device?, kind, target, rule}` → `{id, rule: {…a line…}}`.    public static let keepSet = "keep.set"    /// `{device?, kind, target}` → `{id, cleared}`.    public static let keepClear = "keep.clear"}public struct KeepRulesRequest: Encodable, Sendable {    public let device: String?    public init(device: String? = nil) { self.device = device }}public struct KeepSetRequest: Encodable, Sendable {    public let device: String?    public let kind: String    public let target: String    public let rule: String    public init(device: String? = nil, kind: String, target: String, rule: String) {        self.device = device        self.kind = kind        self.target = target        self.rule = rule    }}public struct KeepClearRequest: Encodable, Sendable {    public let device: String?    public let kind: String    public let target: String    public init(device: String? = nil, kind: String, target: String) {        self.device = device        self.kind = kind        self.target = target    }}// What a phone FETCHES by its keep rules (keepfetch, 12 Oct 2026): the cap// and the core's own lines. The queue and every count are the core's; this// side only draws them.extension CottonMethod {    /// Storage's saved measurement, as a generic storage record; never measures files.    public static let readStorageFacts = "read.storageFacts"}