//! "Re-key this device": the act on the This device page that replaced the//! key this device signs with. A succession is approved by another device of//! the database's household Mac, and this device signs no request to one, so//! the act answers the platform action and refuses the succession itself.use serde_json::{json, Value};usecrate::handle::CottonHandle;usecrate::methods::MethodError;/// The methods of the act. `device.rekey` is the definition command's; the/// others are the app's half of it.pubconst METHODS: [&str; 5] = ["device.rekey", "device.rekey.start", "device.rekey.status", "device.rekey.cancel", "device.rekey.resume"];pubfn call(_handle: &CottonHandle, method: &str, _request: &Value) -> Result<Value, MethodError> {match method {"device.rekey" => Ok(json!({ "platform_action": "rekey_device" })),"device.rekey.start" | "device.rekey.resume" => {Err(MethodError::new("device_key_unreadable", "this device has no key to replace")) }"device.rekey.status" => Ok(json!({ "stage": "idle" })),"device.rekey.cancel" => Ok(json!({ "cancelled": true })), other => Err(MethodError::new("unknown_method", format!("`{other}` is not a re-key method"))), }}