//! `device.serveFrom {deviceId}` — THE OWNER SAYS WHICH MAC SERVES, on the//! Mac that is to serve.//!//! Serving moves only by the CURRENT server's owner-signed grant//! (`cotton_server::serving_move`), and the Mac that is to serve PULLS it//! (architect's ruling, 20 Oct 2026): it asks the Mac that serves its//! household over the household's own name, that Mac's owner act grants it//! each database and hands each whole, and it serves them once each is//! verified and ready (`methods::serving_pull`). So the one call that moves//! serving names THIS Mac, made on it. A call naming another device is//! refused, typed, with nothing asked of anyone: that Mac asks for itself.use serde_json::Value;usecrate::handle::CottonHandle;usecrate::methods::MethodError;pubconst METHOD: &str = "device.serveFrom";/// `cotton_server::serving_move::refusal`'s codes, spelled here because a/// phone build has no server (a guard holds them equal on a Mac build).pub(crate) const ASK_ON_THAT_MAC: &str = "serving_move_ask_on_that_mac";/// A Mac build answers with the server's own; the guard still reads this one.pub(crate) const NOT_A_MAC: &str = "serving_move_not_a_mac";/// `device.serveFrom {deviceId}`.pubfn call(handle: &CottonHandle, request: &Value) -> Result<Value, MethodError> {let mac = request .get("deviceId") .and_then(Value::as_str) .map(str::trim) .filter(|id| !id.is_empty()) .ok_or_else(|| MethodError::new("bad_request", "`deviceId` names the Mac that is to serve"))? .to_string();let this_device = handle.client().self_device_id();if this_device.as_deref() != Some(mac.as_str()) {returnErr(MethodError::new( ASK_ON_THAT_MAC,"A Mac takes serving over itself: open Cotton on that Mac and choose Serve from this Mac there. Nothing has been changed.", )); } pull_the_household(handle)}fn pull_the_household(_handle: &CottonHandle) -> Result<Value, MethodError> {Err(MethodError::new(NOT_A_MAC, "Only a Mac serves a household"))}