//! What a connection refuses, as a typed fact. The words are the database's//! `refusal.connections.*` lines, said at the reading edge — a rewording is a//! row, never a build.use cotton_core::rules::shell_lines::{self, LineRow};usecrate::mcp::dispatch::Ctx;usecrate::mcp::protocol::ToolFailure;#[derive(Debug, Clone, PartialEq, Eq)]pubenumConnectionRefusal {/// The row is gone (deleted, or never here).Gone,/// Read now on a paused connection.Paused,/// Stories switched on a connection that has none.NoStories,/// Gmail's bin switched on a connection that is not a Google account.NotGoogle,/// `config` is neither an object nor JSON text of one.SettingsUnreadable,/// An MCP server address that does not parse.NotAUrl { url: String },/// An MCP server address with no host.NoHost { url: String },/// Plain http to a host that is not on this Mac.PlainHttp { url: String },/// A scheme that is not http or https.NotAWebScheme { url: String, scheme: String },/// A known hosted gateway: a middleman that reads every row.Gateway { host: String, gateway: String },}implConnectionRefusal {/// The one sentence a person or an assistant reads, in `lines`' words. #[must_use]pubfn sentence(&self, lines: &[LineRow]) -> String {matchself {Self::Gone => say(lines, "connections.gone", &[]),Self::Paused => say(lines, "connections.paused", &[]),Self::NoStories => say(lines, "connections.no_stories", &[]),Self::NotGoogle => say(lines, "connections.not_google", &[]),Self::SettingsUnreadable => say(lines, "connections.settings_unreadable", &[]),Self::NotAUrl { url } => say(lines, "connections.not_a_url", &[("url", url)]),Self::NoHost { url } => say(lines, "connections.no_host", &[("url", url)]),Self::PlainHttp { url } => say(lines, "connections.plain_http", &[("url", url)]),Self::NotAWebScheme { url, scheme } => { say(lines, "connections.not_a_web_scheme", &[("url", url), ("scheme", scheme)]) }Self::Gateway { host, gateway } => { say(lines, "connections.gateway", &[("host", host), ("gateway", gateway)]) } } }/// The refusal as a tool failure, said with this database's lines. #[must_use]pubfn failure(&self, ctx: &Ctx<'_>) -> ToolFailure {ToolFailure::new(self.sentence(&crate::presentation::line_rows(ctx.read.driver(), ctx.workspace_id))) }}/// The warning on a server that is neither the service's own nor on this/// Mac: allowed, if the person insists.#[must_use]pubfn third_party_warning(host: &str, lines: &[LineRow]) -> String { say(lines, "connections.third_party", &[("host", host)])}/// The third-party warning, asked to be confirmed before a sign-in starts.#[must_use]pubfn unverified(warning: &str, lines: &[LineRow]) -> String { say(lines, "connections.unverified", &[("warning", warning)])}fn say(lines: &[LineRow], line: &str, fills: &[(&str, &str)]) -> String { shell_lines::resolve("refusal", line, lines, fills).unwrap_or_else(|| format!("refusal.{line}"))}#[cfg(test)]#[path = "refusal_tests.rs"]mod refusal_tests;