example_webserver_rs/
structs.rs1use serde::{Deserialize, Serialize};
3
4#[derive(Deserialize)]
6pub struct RequestJson {
7 pub data: String,
8}
9
10#[derive(Serialize)]
12pub struct ResponseJson {
13 pub output: String,
14}
15
16#[derive(Debug, Clone)]
18pub struct AppState {
19 counter: u32,
20}
21
22impl AppState {
24 pub fn new() -> Self {
25 Self { counter: 0 }
26 }
27 pub fn get_counter(&self) -> &u32 {
28 &self.counter
29 }
30 pub fn increment(&mut self) {
31 self.counter += 1;
32 }
33}
34
35#[derive(Serialize, Deserialize, Debug)]
37pub struct Country {
38 name: Name,
39}
40
41#[derive(Serialize, Deserialize, Debug)]
43pub struct Name {
44 common: String,
45 official: String,
46}
47
48#[derive(Deserialize, Debug)]
50pub struct CountryQueryParams {
51 pub name: String,
52}