use fundamentum_edge_proto::com::fundamentum::edge::v1::{ states_event_server::{StatesEvent, StatesEventServer}, StateJsonData, }; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use tonic::transport::Server; use tonic::{Request, Response, Status}; #[derive(Default)] pub struct StatesEventService {} impl StatesEventService { pub fn new() -> Self { Self {} } } #[tonic::async_trait] impl StatesEvent for StatesEventService { async fn publish_json(&self, request: Request) -> Result, Status> { let req = request.into_inner(); println!("Received: {:?}", req); Ok(Response::new(())) } } #[tokio::main] async fn main() -> Result<(), Box> { let socket_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); let states_event_svc = StatesEventService::new(); let router = Server::builder().add_service(StatesEventServer::new(states_event_svc)); router.serve(socket_addr).await?; Ok(()) }