This commit is contained in:
2025-09-08 03:12:03 +10:00
parent a84711b1f3
commit 3cbeb5a2ad
6 changed files with 27 additions and 13 deletions

View File

@@ -1,3 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::cell::CellRef;
use crate::grid::Grid;
use crate::parser::*;
@@ -5,7 +7,8 @@ use crate::tokenizer::Literal;
use std::collections::HashSet;
use std::fmt;
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Eval {
Literal(Literal),
CellRef { eval: Box<Eval>, reference: CellRef },

View File

@@ -11,10 +11,8 @@ use std::{env, io::Error};
use tokio::net::{TcpListener, TcpStream};
use crate::{
evaluator::Eval,
grid::Grid,
messages::{LeadMsg, MsgType},
tokenizer::Literal,
};
#[tokio::main]
@@ -70,15 +68,11 @@ async fn accept_connection(stream: TcpStream) {
for update in &updates {
if let Ok(cell) = grid.get_cell(*update) {
let Eval::Literal(lit) = cell.eval() else {
continue;
};
msgs.push(LeadMsg {
msg_type: MsgType::Set,
cell: Some(*update),
raw: Some(cell.raw()),
eval: Some(lit),
eval: Some(cell.eval()),
bulk_msgs: None,
});
}

View File

@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::{cell::CellRef, tokenizer::Literal};
use crate::{cell::CellRef, evaluator::Eval};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
@@ -16,6 +16,6 @@ pub struct LeadMsg {
pub msg_type: MsgType,
pub cell: Option<CellRef>,
pub raw: Option<String>,
pub eval: Option<Literal>,
pub eval: Option<Eval>,
pub bulk_msgs: Option<Vec<LeadMsg>>,
}