1use serde::{Deserialize, Serialize};
5use std::path::Path;
6use thiserror::Error;
7
8use crate::*;
9
10pub type KernelResult<T> = Result<T, KernelError>;
12
13#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
16pub struct BodyHandle(pub u64);
17
18#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
20#[derive(Debug, Clone, Default, Serialize, Deserialize)]
21pub struct RebuildRequest {
22 pub dirty_features: Vec<String>,
24 pub propagate: bool,
26}
27
28#[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
30#[derive(Debug, Clone, Default, Serialize, Deserialize)]
31pub struct RebuildResponse {
32 #[allow(deprecated)]
34 pub updated_bodies: Vec<BodyHandle>,
35 pub diagnostics: Vec<String>,
37}
38
39#[allow(deprecated)]
41pub trait Kernel: Send {
42 fn name(&self) -> &str;
44
45 fn initialize(&mut self) -> KernelResult<()>;
47
48 #[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
50 fn rebuild(&mut self, _request: &RebuildRequest) -> KernelResult<RebuildResponse> {
51 Err(KernelError::Unsupported("rebuild".into()))
52 }
53
54 #[deprecated(since = "0.1.6", note = "never called; removed in 0.2")]
56 fn tessellate(
57 &self,
58 _body: BodyHandle,
59 _detail: &TessellationSettings,
60 ) -> KernelResult<TriMesh> {
61 Err(KernelError::Unsupported("tessellate".into()))
62 }
63
64 fn import_step(
69 &mut self,
70 _path: &Path,
71 _detail: &TessellationSettings,
72 ) -> KernelResult<ImportedModel> {
73 Err(KernelError::Unsupported(
74 "STEP import is not implemented by this kernel".into(),
75 ))
76 }
77}
78
79#[derive(Debug, Error)]
81pub enum KernelError {
82 #[error("kernel initialization failed: {0}")]
83 Initialization(String),
84 #[error("kernel not initialized")]
85 NotInitialized,
86 #[error("operation unsupported: {0}")]
87 Unsupported(String),
88 #[error("invalid kernel input: {0}")]
89 InvalidInput(String),
90 #[error("import failed: {0}")]
91 Import(String),
92 #[error(transparent)]
93 Other(#[from] anyhow::Error),
94}