//! `camera.shot` — a shot from the Camera tool, saved the moment it is taken.//!//! A shot is `capture.media` (the bytes, the photo row, the upload ledger, in//! that order), held to what a camera makes: a photo or a video.use serde_json::Value;use cotton_client::layout::Layout;use cotton_core::media::keys::MediaKind;use cotton_tools::mcp::dispatch::Ctx;usecrate::handle::CottonHandle;usecrate::methods::MethodError;usecrate::phone::media::{validate_capture, write_media, CaptureMediaArgs};pubfn shot(handle: &CottonHandle, request: &Value) -> Result<Value, MethodError> {let args = validate_shot(request)?;let client = handle.client();let layout = client.layout().clone();let device_key = client.self_device_id();let answer = client .write_rows("camera.shot", &mut |ctx| { write_shot(ctx, &layout, &args, device_key.as_deref()) }) .map_err(|reason| MethodError::new("capture_refused", reason))?;Ok(crate::authoring::own_answer(answer))}/// `capture.media`'s arguments, held to what a camera makes.pubfn validate_shot(request: &Value) -> Result<CaptureMediaArgs, MethodError> {let args = validate_capture(request)?;if !matches!(args.kind, MediaKind::Photo | MediaKind::Video) {returnErr(MethodError::new("bad_request", "a camera shot is a photo or a video")); }Ok(args)}/// The shot, so a test can drive it over a `Ctx`.pubfn write_shot( ctx: &mutCtx<'_>, layout: &Layout, args: &CaptureMediaArgs, device_key: Option<&str>,) -> Result<Value, String> { write_media(ctx, layout, args, device_key)}