Skip to main content

entrenar/research/notebook/
kernel.rs

1//! Jupyter kernel specifications.
2
3use serde::{Deserialize, Serialize};
4
5/// Jupyter kernel specification
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub struct KernelSpec {
8    /// Display name
9    pub display_name: String,
10    /// Language
11    pub language: String,
12    /// Kernel name
13    pub name: String,
14}
15
16impl Default for KernelSpec {
17    fn default() -> Self {
18        Self::python3()
19    }
20}
21
22impl KernelSpec {
23    /// Python 3 kernel
24    pub fn python3() -> Self {
25        Self {
26            display_name: "Python 3".to_string(),
27            language: "python".to_string(),
28            name: "python3".to_string(),
29        }
30    }
31
32    /// evcxr Rust kernel
33    pub fn evcxr() -> Self {
34        Self {
35            display_name: "Rust".to_string(),
36            language: "rust".to_string(),
37            name: "rust".to_string(),
38        }
39    }
40
41    /// Julia kernel
42    pub fn julia() -> Self {
43        Self {
44            display_name: "Julia 1.9".to_string(),
45            language: "julia".to_string(),
46            name: "julia-1.9".to_string(),
47        }
48    }
49}