KeiSeiKit-1.0/_primitives/_rust/kei-net-wireguard/src/error.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

46 lines
1.3 KiB
Rust

// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 <author org>
//!
//! Error types for `kei-net-wireguard`. Maps cleanly into
//! `kei_runtime_core::Error` so `WireguardMode` can fulfill `NetworkMode`.
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
/// `wg-quick`/`wg` exited non-zero. Carries the rendered command line +
/// stderr tail for diagnostics.
#[error("wg cmd: {0}")]
WgCmd(String),
/// Underlying I/O failure (spawn / read / wait).
#[error("io: {0}")]
Io(#[from] std::io::Error),
/// `wg show ... dump` produced output we could not parse.
#[error("parse: {0}")]
Parse(String),
/// DNA construction failed.
#[error("dna: {0}")]
Dna(String),
}
pub type Result<T> = std::result::Result<T, Error>;
impl From<kei_runtime_core::DnaError> for Error {
fn from(e: kei_runtime_core::DnaError) -> Self {
Error::Dna(e.to_string())
}
}
impl From<Error> for kei_runtime_core::Error {
fn from(e: Error) -> Self {
match e {
Error::WgCmd(s) => kei_runtime_core::Error::Network(format!("wg: {s}")),
Error::Io(e) => kei_runtime_core::Error::Io(e),
Error::Parse(s) => kei_runtime_core::Error::Network(format!("parse: {s}")),
Error::Dna(s) => kei_runtime_core::Error::Other(format!("dna: {s}")),
}
}
}