Skip to main content

sapphire_framework_server_api/
lib.rs

1//! What a client says to an application's server, and how the server answers: the
2//! framework's methods every app server serves, their parameters and their results.
3//!
4//! Kept apart from the rest of the framework so that its version moves only when this
5//! API does. An application's own API crate depends on this one and nothing heavier;
6//! a client that only talks to a server links neither the search stack nor the IPC
7//! transport through it. Its types are plain serde data: the transport is
8//! `sapphire-framework-ipc`, the typed client `IpcBackend` in
9//! `sapphire-framework-backend`.
10//!
11//! A server serves one workspace at a time (#215), so no request names one: every
12//! `workspace.*` and `sync.*` method acts on the server's current workspace, which
13//! [`WORKSPACE_SELECT`] and [`WORKSPACE_INIT`] change, [`WORKSPACE_MOVE`] and
14//! [`WORKSPACE_REMOVE`] relocate or let go of, and [`WORKSPACE_CURRENT`] reports.
15
16#![warn(missing_docs)]
17
18use std::path::PathBuf;
19
20use serde::{Deserialize, Serialize};
21
22pub use grain_id::GrainId;
23
24/// The bridge's API, for the methods an app server relays to it ([`bridge::RELAYED`]) and
25/// the types they carry, so a client needs no second dependency.
26pub use sapphire_bridge_api as bridge;
27
28/// The version of the app server's API: the framework's methods below and their types.
29///
30/// It is this crate's major version, parsed at compile time, so the two cannot drift: a
31/// breaking change to a method, a parameter or a result here is a major release of this
32/// crate, and that release is the new API version. The handshake compares this number,
33/// not the framework's version, so a framework release that leaves this crate alone
34/// does not demand a service restart.
35///
36/// 2: `workspace.list`, `workspace.forget`.
37///
38/// 3: search results carry `snippet` in place of `chunks` (#184).
39///
40/// 4: one workspace per server (#215): no `ws` parameter, `workspace.select` and
41/// `workspace.current` in place of `workspace.list` and `workspace.forget`.
42pub const API_VERSION: u32 = parse_major(env!("CARGO_PKG_VERSION_MAJOR"));
43
44/// `CARGO_PKG_VERSION_MAJOR` as a number. Cargo guarantees it is decimal digits.
45const fn parse_major(s: &str) -> u32 {
46    let bytes = s.as_bytes();
47    let mut i = 0;
48    let mut n = 0u32;
49    while i < bytes.len() {
50        n = n * 10 + (bytes[i] - b'0') as u32;
51        i += 1;
52    }
53    n
54}
55
56/// How a server process came to exist, as `server.info` reports it.
57///
58/// The same shape as `sapphire_ipc::ManagedBy`, defined here so this crate does not
59/// depend on the transport.
60#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
61#[serde(rename_all = "lowercase")]
62pub enum ManagedBy {
63    /// Started by the OS service manager.
64    Service,
65    /// Started on demand by a client.
66    Spawned,
67}
68
69/// Which retrieval strategy a search uses.
70#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
71#[serde(rename_all = "lowercase")]
72pub enum SearchMode {
73    /// Full-text search only (BM25 / trigram).
74    Fts,
75    /// Semantic (vector) search only. Falls back to full text if no embedder is
76    /// configured.
77    Semantic,
78    /// Combine full-text and semantic results via Reciprocal Rank Fusion (default).
79    #[default]
80    Hybrid,
81}
82
83/// One file matching a search.
84#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
85pub struct FileSearchResult {
86    /// The index's id for the file. Stable only within one server's index.
87    pub id: i64,
88    /// The file's path, relative to the workspace root.
89    pub path: String,
90    /// Full text: BM25 (higher is better). Semantic: L2 distance (lower is better).
91    /// Hybrid: RRF (higher is better).
92    pub score: f64,
93    /// A short excerpt, on one line: the match's surroundings, else the leading text.
94    pub snippet: String,
95}
96
97/// Events a server publishes so a client can react without polling.
98#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
99pub enum BackendEvent {
100    /// A sync cycle finished.
101    Synced {
102        /// Documents added/updated.
103        upserted: usize,
104        /// Documents removed.
105        removed: usize,
106    },
107    /// A single file changed through the server.
108    FileChanged {
109        /// The affected path.
110        path: PathBuf,
111    },
112    /// A single file was removed through the server.
113    FileRemoved {
114        /// The affected path.
115        path: PathBuf,
116    },
117    /// A background operation failed. Carries a human-readable message.
118    Error {
119        /// Failure description.
120        message: String,
121    },
122    /// Every edit this device made to the synced workspace has reached at least one peer:
123    /// the peer applied it and wrote its content, so it survives this device going to sleep
124    /// or away.
125    ///
126    /// Sent once per batch of edits, when the last of them lands, not once per peer: a second
127    /// peer catching up later says nothing new. Edits made before sync started on this
128    /// server are not waited for. [`SyncStatusResult::pending_delivery`] says the same thing
129    /// to a client that asks instead.
130    SyncDelivered {
131        /// The peer that confirmed them.
132        device_id: grain_id::GrainId,
133        /// That peer's name, as the workgroup lists it; its id when the name is not known.
134        device_name: String,
135    },
136}
137
138/// Search the workspace.
139pub const SEARCH: &str = "workspace.search";
140/// Read a text file in full.
141pub const READ_FILE: &str = "workspace.read_file";
142/// Create or overwrite a text file.
143pub const WRITE_FILE: &str = "workspace.write_file";
144/// Append to a text file.
145pub const APPEND_FILE: &str = "workspace.append_file";
146/// Delete a file.
147pub const DELETE_FILE: &str = "workspace.delete_file";
148/// List a directory's direct children.
149pub const LIST_DIR: &str = "workspace.list_dir";
150/// Rebuild the index from disk.
151///
152/// Named `reindex`, not `sync`: `WorkspaceBackend::sync`
153/// means "walk the files and update the index", which reads as peer-to-peer sync once the
154/// bridge exists.
155pub const REINDEX: &str = "workspace.reindex";
156/// Start receiving [`EVENT`] notifications for the current workspace, and for whichever
157/// workspace is current after a switch.
158pub const SUBSCRIBE: &str = "workspace.subscribe";
159/// Create this app's workspace home in a directory — the folder when missing, and its marker —
160/// and make it the current workspace.
161pub const WORKSPACE_INIT: &str = "workspace.init";
162/// Make an existing workspace of this app the current one.
163pub const WORKSPACE_SELECT: &str = "workspace.select";
164/// Report the current workspace.
165pub const WORKSPACE_CURRENT: &str = "workspace.current";
166/// Move the current workspace's folder elsewhere on this host, and keep serving it there.
167pub const WORKSPACE_MOVE: &str = "workspace.move";
168/// Stop serving the current workspace, optionally deleting its folder.
169pub const WORKSPACE_REMOVE: &str = "workspace.remove";
170
171/// Parameters of [`WORKSPACE_MOVE`]. The result is the [`CurrentWorkspace`] at its new
172/// root.
173#[derive(Clone, Debug, Deserialize, Serialize)]
174pub struct WorkspaceMoveParams {
175    /// The new root: absolute, or relative to the server's cwd. It must not exist yet;
176    /// its parent must.
177    pub dir: PathBuf,
178}
179
180/// Parameters of [`WORKSPACE_REMOVE`]. The result is an [`Ack`]; the server has no
181/// workspace afterwards.
182///
183/// Sync stops for this host only: the workspace stays in the workgroup, and other
184/// devices keep their copies.
185#[derive(Clone, Debug, Default, Deserialize, Serialize)]
186pub struct WorkspaceRemoveParams {
187    /// Also delete the workspace's folder, every file in it, and its cache.
188    #[serde(default)]
189    pub delete: bool,
190}
191
192/// Parameters of [`WORKSPACE_SELECT`].
193#[derive(Clone, Debug, Deserialize, Serialize)]
194pub struct WorkspaceSelectParams {
195    /// The workspace's root: absolute, or relative to the server's cwd.
196    pub dir: PathBuf,
197}
198
199/// Result of [`WORKSPACE_CURRENT`].
200#[derive(Clone, Debug, Default, Deserialize, Serialize)]
201pub struct WorkspaceCurrentResult {
202    /// The current workspace; `None` before one is selected.
203    pub workspace: Option<CurrentWorkspace>,
204}
205
206/// The workspace a server serves, as [`WORKSPACE_CURRENT`] and [`WORKSPACE_SELECT`]
207/// report it.
208#[derive(Clone, Debug, Deserialize, Serialize)]
209pub struct CurrentWorkspace {
210    /// Its root on this host.
211    pub root: PathBuf,
212    /// Its identity across devices, when one has been minted. Read, never minted.
213    pub workspace_id: Option<grain_id::GrainId>,
214    /// Whether the root still holds this application's marker directory.
215    pub reachable: bool,
216    /// Its replication state, as [`SYNC_STATUS`] reports it.
217    pub sync: SyncStatusResult,
218}
219
220/// Parameters of [`WORKSPACE_INIT`].
221#[derive(Clone, Debug, Deserialize, Serialize)]
222pub struct WorkspaceInitParams {
223    /// Where the workspace root goes, relative to nothing: absolute, or relative
224    /// to the process's cwd, resolved by the server.
225    pub dir: PathBuf,
226}
227
228/// Result of [`WORKSPACE_INIT`].
229#[derive(Clone, Debug, Deserialize, Serialize)]
230pub struct WorkspaceInitResult {
231    /// The workspace's canonical root.
232    pub root: PathBuf,
233    /// The root's directory name, slugified. Nothing keys by it any more: it was the id
234    /// of the `[workspace]` registry entry `workspace.init` used to write into the
235    /// marker's `config.toml`, and stays for clients that print it.
236    pub workspace_id: String,
237    /// `false` when the workspace already existed (exit 0 either way).
238    pub created: bool,
239}
240/// Notification carrying one [`BackendEvent`].
241pub const EVENT: &str = "workspace.event";
242/// What the server knows about itself.
243pub const SERVER_INFO: &str = "server.info";
244/// What the server last learnt about newer releases of itself: [`UpdateStatus`].
245///
246/// A server older than this method answers method-not-found; a client reads that as
247/// "nothing known" rather than an error.
248pub const SERVER_UPDATE: &str = "server.update";
249/// Restart the app server in place: it answers [`Ack`], stops what it serves (HTTP, sync,
250/// the update check, open connections), reads its settings again and serves anew on the
251/// same endpoint, in the same process. A client reconnects to reach the new server.
252///
253/// A server that cannot restart itself (one not run by the framework's restarting entry
254/// point) answers an error; a server older than this method answers method-not-found.
255pub const SERVER_RESTART: &str = "server.restart";
256
257/// Parameters naming a path inside the workspace.
258#[derive(Clone, Debug, Serialize, Deserialize)]
259pub struct PathParams {
260    /// Workspace-relative path.
261    pub path: PathBuf,
262}
263
264/// Parameters naming a path and the text to put there.
265#[derive(Clone, Debug, Serialize, Deserialize)]
266pub struct ContentParams {
267    /// Workspace-relative path.
268    pub path: PathBuf,
269    /// The text.
270    pub content: String,
271}
272
273/// Parameters of [`SEARCH`].
274#[derive(Clone, Debug, Serialize, Deserialize)]
275pub struct SearchParams {
276    /// The query.
277    pub query: String,
278    /// Maximum number of files to return.
279    pub limit: usize,
280    /// Which retrieval strategy to use.
281    #[serde(default)]
282    pub mode: SearchMode,
283}
284
285/// Result of [`SEARCH`].
286#[derive(Clone, Debug, Serialize, Deserialize)]
287pub struct SearchResult {
288    /// File-level hits, best first.
289    pub hits: Vec<FileSearchResult>,
290}
291
292/// Result of [`READ_FILE`].
293#[derive(Clone, Debug, Serialize, Deserialize)]
294pub struct ReadResult {
295    /// The file's contents.
296    pub content: String,
297}
298
299/// One entry of a directory listing.
300#[derive(Clone, Debug, Serialize, Deserialize)]
301pub struct DirEntry {
302    /// The child's path.
303    pub path: PathBuf,
304    /// Whether it is a directory.
305    pub is_dir: bool,
306}
307
308/// Result of [`LIST_DIR`].
309#[derive(Clone, Debug, Serialize, Deserialize)]
310pub struct ListDirResult {
311    /// The direct children.
312    pub entries: Vec<DirEntry>,
313}
314
315/// Result of [`REINDEX`].
316#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
317pub struct ReindexResult {
318    /// Documents added or updated.
319    pub upserted: usize,
320    /// Documents removed.
321    pub removed: usize,
322}
323
324/// The success payload of a method that returns nothing.
325///
326/// An empty object rather than `null`, so that a later release can add a field without
327/// changing the shape of the response.
328#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)]
329pub struct Ack {}
330
331/// Parameters of an [`EVENT`] notification.
332#[derive(Clone, Debug, Serialize, Deserialize)]
333pub struct EventParams {
334    /// The root of the workspace the event came from: the current one when it was sent.
335    pub ws: PathBuf,
336    /// What happened.
337    pub event: BackendEvent,
338}
339
340#[cfg(test)]
341mod tests {
342    use super::*;
343
344    fn round_trip<T>(value: &T) -> T
345    where
346        T: serde::Serialize + serde::de::DeserializeOwned,
347    {
348        serde_json::from_value(serde_json::to_value(value).unwrap()).unwrap()
349    }
350
351    #[test]
352    fn search_parameters_round_trip() {
353        let params = SearchParams {
354            query: "hello".into(),
355            limit: 10,
356            mode: SearchMode::Fts,
357        };
358        let back = round_trip(&params);
359        assert_eq!(back.query, "hello");
360        assert_eq!(back.limit, 10);
361        assert_eq!(back.mode, SearchMode::Fts);
362    }
363
364    #[test]
365    fn every_search_mode_has_a_stable_lowercase_name() {
366        for (mode, name) in [
367            (SearchMode::Fts, "fts"),
368            (SearchMode::Semantic, "semantic"),
369            (SearchMode::Hybrid, "hybrid"),
370        ] {
371            assert_eq!(serde_json::to_value(mode).unwrap(), serde_json::json!(name));
372            assert_eq!(
373                serde_json::from_value::<SearchMode>(serde_json::json!(name)).unwrap(),
374                mode
375            );
376        }
377    }
378
379    #[test]
380    fn a_missing_mode_defaults_to_hybrid() {
381        let value = serde_json::json!({ "query": "q", "limit": 5 });
382        let params: SearchParams = serde_json::from_value(value).unwrap();
383        assert_eq!(params.mode, SearchMode::Hybrid);
384    }
385
386    #[test]
387    fn every_backend_event_round_trips() {
388        for event in [
389            BackendEvent::Synced {
390                upserted: 3,
391                removed: 1,
392            },
393            BackendEvent::FileChanged {
394                path: PathBuf::from("a.md"),
395            },
396            BackendEvent::FileRemoved {
397                path: PathBuf::from("b.md"),
398            },
399            BackendEvent::Error {
400                message: "boom".into(),
401            },
402            BackendEvent::SyncDelivered {
403                device_id: grain_id::GrainId::random(),
404                device_name: "laptop".into(),
405            },
406        ] {
407            assert_eq!(round_trip(&event), event);
408        }
409    }
410
411    #[test]
412    fn a_directory_listing_round_trips() {
413        let listing = ListDirResult {
414            entries: vec![
415                DirEntry {
416                    path: PathBuf::from("notes"),
417                    is_dir: true,
418                },
419                DirEntry {
420                    path: PathBuf::from("a.md"),
421                    is_dir: false,
422                },
423            ],
424        };
425        let back = round_trip(&listing);
426        assert_eq!(back.entries.len(), 2);
427        assert!(back.entries[0].is_dir);
428        assert!(!back.entries[1].is_dir);
429    }
430
431    #[test]
432    fn an_ack_is_an_object_not_null() {
433        assert_eq!(serde_json::to_value(Ack {}).unwrap(), serde_json::json!({}));
434    }
435
436    #[test]
437    fn workspace_init_params_and_result_round_trip() {
438        let params = WorkspaceInitParams {
439            dir: PathBuf::from("/home/me/papers"),
440        };
441        let back = round_trip(&params);
442        assert_eq!(back.dir, params.dir);
443
444        let result = WorkspaceInitResult {
445            root: PathBuf::from("/home/me/papers"),
446            workspace_id: "g123".into(),
447            created: true,
448        };
449        let back = round_trip(&result);
450        assert_eq!(back.root, result.root);
451        assert_eq!(back.workspace_id, result.workspace_id);
452        assert!(back.created);
453    }
454
455    #[test]
456    fn the_current_workspace_round_trips() {
457        let current = CurrentWorkspace {
458            root: PathBuf::from("/home/me/notes"),
459            workspace_id: Some(grain_id::GrainId::random()),
460            reachable: true,
461            sync: SyncStatusResult::not_synced(),
462        };
463        let back = round_trip(&WorkspaceCurrentResult {
464            workspace: Some(current.clone()),
465        });
466        let back = back.workspace.unwrap();
467        assert_eq!(back.root, current.root);
468        assert_eq!(back.workspace_id, current.workspace_id);
469        assert!(
470            round_trip(&WorkspaceCurrentResult::default())
471                .workspace
472                .is_none()
473        );
474        assert_eq!(
475            round_trip(&WorkspaceSelectParams {
476                dir: PathBuf::from("/x")
477            })
478            .dir,
479            PathBuf::from("/x")
480        );
481        assert_eq!(API_VERSION, 7, "the crate's major is the API version");
482    }
483
484    #[test]
485    fn method_names_are_namespaced() {
486        for name in [
487            SEARCH,
488            READ_FILE,
489            WRITE_FILE,
490            APPEND_FILE,
491            DELETE_FILE,
492            LIST_DIR,
493            REINDEX,
494            SUBSCRIBE,
495            WORKSPACE_INIT,
496            WORKSPACE_SELECT,
497            WORKSPACE_CURRENT,
498            WORKSPACE_MOVE,
499            WORKSPACE_REMOVE,
500        ] {
501            assert!(name.starts_with("workspace."), "{name}");
502        }
503        assert_eq!(EVENT, "workspace.event");
504    }
505}
506
507/// Start syncing the current workspace.
508pub const SYNC_ENABLE: &str = "sync.enable";
509/// Stop syncing the current workspace. Files stay.
510pub const SYNC_DISABLE: &str = "sync.disable";
511/// Report the current workspace's replication state.
512pub const SYNC_STATUS: &str = "sync.status";
513
514/// Place a workspace's directory, by name or id.
515pub const SYNC_MAP: &str = "sync.map";
516
517/// Parameters of [`SYNC_MAP`]. The mapped directory becomes the current workspace.
518#[derive(Clone, Debug, Deserialize, Serialize)]
519pub struct SyncMapParams {
520    /// The workspace, by name or id, as the workgroup lists it.
521    pub workspace: String,
522    /// Where the workspace's root is on this host.
523    pub dir: PathBuf,
524}
525
526/// Result of [`SYNC_ENABLE`].
527#[derive(Clone, Debug, Deserialize, Serialize)]
528pub struct SyncEnableResult {
529    /// The workspace's identity across devices.
530    pub workspace_id: grain_id::GrainId,
531}
532
533/// How a synced workspace is wired to its peers right now.
534#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
535#[serde(tag = "kind", rename_all = "snake_case")]
536pub enum Topology {
537    /// Every device syncs with every other. Also the answer when no device was elected.
538    #[default]
539    Mesh,
540    /// Devices that are neither primary nor secondary sync only with those two.
541    Star {
542        /// The primary device.
543        primary: grain_id::GrainId,
544        /// The secondary device, if there is a second candidate.
545        secondary: Option<grain_id::GrainId>,
546    },
547}
548
549/// Result of [`SYNC_STATUS`].
550#[derive(Clone, Debug, Deserialize, Serialize)]
551pub struct SyncStatusResult {
552    /// Whether this workspace is synced.
553    pub enabled: bool,
554    /// Its identity across devices, when it is.
555    pub workspace_id: Option<grain_id::GrainId>,
556    /// How many other devices the workgroup has.
557    pub peers: usize,
558    /// Why replication is paused, if it is.
559    pub paused: Option<String>,
560    /// The last failure, if any.
561    pub last_error: Option<String>,
562    /// Whether the bridge is reachable. `false` does not mean the app server is down.
563    pub bridge_available: bool,
564    /// How the workspace is wired to its peers. Absent from older servers: a mesh.
565    #[serde(default)]
566    pub topology: Topology,
567    /// How far embedding has got, when this host embeds (#188).
568    #[serde(default, skip_serializing_if = "Option::is_none")]
569    pub embedding: Option<EmbeddingProgress>,
570    /// Some edit this device made since sync started on this server has not reached any
571    /// peer yet. [`BackendEvent::SyncDelivered`] is sent when it has.
572    #[serde(default)]
573    pub pending_delivery: bool,
574    /// How many peers have a live session open that confirms what it is sent. With none, a
575    /// pending edit is confirmed only by the next session's exchange — a peer from before
576    /// confirmations never confirms a live push.
577    #[serde(default)]
578    pub acknowledging_peers: usize,
579}
580
581/// How far a workspace's embedding has got on this host.
582#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
583pub struct EmbeddingProgress {
584    /// Documents with a vector.
585    pub vectors: u64,
586    /// Documents still without one.
587    pub pending: u64,
588    /// Whether an embedding pass is running now.
589    pub running: bool,
590}
591
592impl SyncStatusResult {
593    /// The state of a workspace nothing syncs.
594    pub fn not_synced() -> SyncStatusResult {
595        SyncStatusResult {
596            enabled: false,
597            workspace_id: None,
598            peers: 0,
599            paused: None,
600            last_error: None,
601            bridge_available: false,
602            topology: Topology::Mesh,
603            embedding: None,
604            pending_delivery: false,
605            acknowledging_peers: 0,
606        }
607    }
608}
609
610/// The typed answer to a status question, shared by the CLI and the IPC `server.info`
611/// response (spec decision 4).
612///
613/// When a server answers, the CLI prints the framework's fields and then the
614/// application's [rows](StatusReport::app) as `name: value` lines; a GUI could read the
615/// same serialised shape from the IPC method instead. When nothing is listening, the
616/// report is [`StatusReport::running`] = `false` and the app rows are skipped.
617#[derive(Debug, Clone, Serialize, Deserialize)]
618pub struct StatusReport {
619    /// Whether a server is answering at all.
620    pub running: bool,
621    /// The server's version, when it is running.
622    pub version: Option<String>,
623    /// Its pid, when it is running.
624    pub pid: Option<u32>,
625    /// How the running server was started, when it is running.
626    pub managed_by: Option<ManagedBy>,
627    /// The application's own rows, rendered after the framework's.
628    pub app: Vec<StatusRow>,
629}
630
631/// The answer to [`SERVER_UPDATE`]: whether a newer release of the running server exists.
632///
633/// The server only looks; it never downloads or installs anything. Installing the
634/// release and restarting the server are the user's.
635#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
636pub struct UpdateStatus {
637    /// Whether the server looks for releases at all: the application named where its
638    /// releases are published, and `server.toml` did not turn the check off.
639    pub enabled: bool,
640    /// The newest release the last successful check found, whether or not it is newer
641    /// than the running server. `None` until a check has succeeded.
642    pub latest: Option<ReleaseInfo>,
643    /// Whether [`latest`](Self::latest) is newer than the running server.
644    pub update_available: bool,
645    /// Why the last check failed, when it did. A later success clears it; the last
646    /// [`latest`](Self::latest) is kept meanwhile.
647    pub last_error: Option<String>,
648}
649
650/// One published release, as [`UpdateStatus`] reports it.
651#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
652pub struct ReleaseInfo {
653    /// The release's version, without the tag's prefix: `0.20.0`.
654    pub version: String,
655    /// The release's web page, where its notes and downloads are.
656    pub url: String,
657}
658
659/// One application-provided line of the status report.
660#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
661pub struct StatusRow {
662    /// The row's name, e.g. `sync`.
663    pub name: String,
664    /// The value shown beside it.
665    pub value: String,
666}