Name refactor

This commit is contained in:
2026-07-22 18:30:16 +02:00
parent 39735bad87
commit a641de074f
5 changed files with 30 additions and 30 deletions
+2 -2
View File
@@ -27,5 +27,5 @@ name = "pulse-trader"
path = "src/terminal/main.rs"
[[bin]]
name = "pulse-trader-daemon"
path = "src/daemon/main.rs"
name = "pulse-trader-engine"
path = "src/engine/main.rs"
+6 -6
View File
@@ -3,7 +3,7 @@ use quote::quote;
use syn::{Fields, ItemEnum, ItemStruct, parse_macro_input};
#[proc_macro_attribute]
pub fn p_com(_: TokenStream, item: TokenStream) -> TokenStream {
pub fn pwp(_: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as syn::Item);
match input {
@@ -49,7 +49,7 @@ fn expand_struct(mut input: ItemStruct) -> TokenStream {
#[derive(Debug, Clone)]
#input
impl PulseCom for #name {
impl PulseWire for #name {
fn to_com(&self) -> Vec<u8> {
let mut vec = Vec::new();
@@ -63,7 +63,7 @@ fn expand_struct(mut input: ItemStruct) -> TokenStream {
fn from_com(com: &mut Vec<u8>) -> Self {
Self {
#(
#field_names2: PulseCom::from_com(com),
#field_names2: PulseWire::from_com(com),
)*
}
}
@@ -122,7 +122,7 @@ fn expand_enum(input: ItemEnum) -> TokenStream {
Fields::Unnamed(fields) if fields.unnamed.len() == 1 => {
quote! {
#tag => Self::#ident(PulseCom::from_com(com)),
#tag => Self::#ident(PulseWire::from_com(com)),
}
}
@@ -132,7 +132,7 @@ fn expand_enum(input: ItemEnum) -> TokenStream {
quote! {
#tag => Self::#ident {
#(
#names: PulseCom::from_com(com),
#names: PulseWire::from_com(com),
)*
},
}
@@ -146,7 +146,7 @@ fn expand_enum(input: ItemEnum) -> TokenStream {
#[derive(Debug, Clone)]
#input
impl PulseCom for #name {
impl PulseWire for #name {
fn to_com(&self) -> Vec<u8> {
let mut vec = Vec::new();
+4 -4
View File
@@ -1,11 +1,11 @@
pub mod terminal;
pub trait PulseCom {
pub trait PulseWire {
fn to_com(&self) -> Vec<u8>;
fn from_com(_com: &mut Vec<u8>) -> Self;
}
impl<T: PulseCom> PulseCom for Vec<T> {
impl<T: PulseWire> PulseWire for Vec<T> {
fn to_com(&self) -> Vec<u8> {
let mut vec = Vec::new();
@@ -33,7 +33,7 @@ impl<T: PulseCom> PulseCom for Vec<T> {
}
}
impl PulseCom for String {
impl PulseWire for String {
fn to_com(&self) -> Vec<u8> {
let bytes = self.as_bytes();
let mut out = Vec::with_capacity(4 + bytes.len());
@@ -55,7 +55,7 @@ impl PulseCom for String {
macro_rules! int_com {
($t:ty) => {
impl PulseCom for $t {
impl $crate::PulseWire for $t {
fn to_com(&self) -> Vec<u8> {
self.to_le_bytes().to_vec()
}
+17 -17
View File
@@ -1,35 +1,35 @@
use crate::PulseCom;
use pulse_macros::p_com;
use crate::PulseWire;
use pulse_macros::pwp;
#[p_com]
#[pwp]
pub struct WatchListItem {
symbol: String,
price: f64,
trend: f64,
}
#[p_com]
#[pwp]
pub struct ActivePosition {
symbol: String,
profit: f64,
amount: f64,
}
#[p_com]
#[pwp]
pub enum MarketTrend {
Bullish,
Bearish,
Neutral,
}
#[p_com]
#[pwp]
pub enum Volatility {
Low,
Medium,
High,
}
#[p_com]
#[pwp]
pub struct MarketOverview {
trend: MarketTrend,
volatility: Volatility,
@@ -38,7 +38,7 @@ pub struct MarketOverview {
alerts: Vec<Alert>,
}
#[p_com]
#[pwp]
pub enum Feed {
Connected,
Disconnected,
@@ -46,7 +46,7 @@ pub enum Feed {
Failed,
}
#[p_com]
#[pwp]
pub struct Status {
feed: Feed,
exchange: String,
@@ -54,13 +54,13 @@ pub struct Status {
latency: u16,
}
#[p_com]
#[pwp]
pub enum SignalKind {
Buy,
Sell,
}
#[p_com]
#[pwp]
pub enum SignalParameter {
Lim,
Stl,
@@ -68,7 +68,7 @@ pub enum SignalParameter {
Chk,
}
#[p_com]
#[pwp]
pub struct Signal {
kind: SignalKind,
symbol: String,
@@ -76,7 +76,7 @@ pub struct Signal {
price: f64,
}
#[p_com]
#[pwp]
pub enum LogKind {
Info,
Warn,
@@ -84,27 +84,27 @@ pub enum LogKind {
Debug,
}
#[p_com]
#[pwp]
pub struct EventLog {
kind: LogKind,
name: String,
message: String,
}
#[p_com]
#[pwp]
pub enum AlertLevel {
High,
Medium,
Low,
}
#[p_com]
#[pwp]
pub struct Alert {
level: AlertLevel,
message: String,
}
#[p_com]
#[pwp]
pub enum InspectTarget {
None,
Symbol(WatchListItem),
+1 -1
View File
@@ -1,6 +1,6 @@
use std::time::Instant;
use pulse_wire::PulseCom;
use pulse_wire::PulseWire;
fn main() {
let input = pulse_wire::terminal::EventLog {