use serde::{Deserialize, Serialize};
use std::path::Path;
use thiserror::Error;
use crate::*;
pub type KernelResult<T> = Result<T, KernelError>;
#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BodyHandle(pub u64);
#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RebuildRequest {
pub dirty_features: Vec<String>,
pub propagate: bool,
}
#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RebuildResponse {
#[allow(deprecated)]
pub updated_bodies: Vec<BodyHandle>,
pub diagnostics: Vec<String>,
}
#[allow(deprecated)]
pub trait Kernel: Send {
fn name(&self) -> &str;
fn initialize(&mut self) -> KernelResult<()>;
#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
fn rebuild(&mut self, _request: &RebuildRequest) -> KernelResult<RebuildResponse> {
Err(KernelError::Unsupported("rebuild".into()))
}
#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
fn tessellate(
&self,
_body: BodyHandle,
_detail: &TessellationSettings,
) -> KernelResult<TriMesh> {
Err(KernelError::Unsupported("tessellate".into()))
}
fn import_step(
&mut self,
_path: &Path,
_detail: &TessellationSettings,
) -> KernelResult<ImportedModel> {
Err(KernelError::Unsupported(
"STEP import is not implemented by this kernel".into(),
))
}
}
#[derive(Debug, Error)]
pub enum KernelError {
#[error("kernel initialization failed: {0}")]
Initialization(String),
#[error("kernel not initialized")]
NotInitialized,
#[error("operation unsupported: {0}")]
Unsupported(String),
#[error("invalid kernel input: {0}")]
InvalidInput(String),
#[error("import failed: {0}")]
Import(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
}