Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 15, 2024
1 parent 937ddab commit 6c1494c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
6 changes: 2 additions & 4 deletions src/handler/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,12 @@ pub mod update_client {

let path = data_str(json, "path");
let point = data_u64(json, "point");
let region_start = data_u64(json, "region_start");
let region_beg = data_u64(json, "region_beg");
let region_end = data_u64(json, "region_end");

let user = client.user_mut().unwrap();

//let region = to_region(region_start, region_end);

user.update(path, point, region_start, region_end);
user.update(path, point, region_beg, region_end);
}
}

Expand Down
26 changes: 4 additions & 22 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,12 @@
*/
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub struct Region {
pub start: Option<u64>,
pub end: Option<u64>,
}

impl Region {
pub fn new(_start: Option<u64>, _end: Option<u64>) -> Self {
Self {
start: _start,
end: _end,
}
}
}

#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub struct User {
pub username: String,
pub path: Option<String>, // the user's location
pub point: Option<u64>,
//pub region: Option<Region>,
pub region_start: Option<u64>,
pub region_beg: Option<u64>,
pub region_end: Option<u64>,
}

Expand All @@ -46,8 +30,7 @@ impl User {
username: _username,
path: None,
point: None,
//region: None,
region_start: None,
region_beg: None,
region_end: None,
}
}
Expand All @@ -56,13 +39,12 @@ impl User {
&mut self,
path: Option<String>,
point: Option<u64>,
region_start: Option<u64>,
region_beg: Option<u64>,
region_end: Option<u64>,
) {
self.path = path;
self.point = point;
//self.region = region;
self.region_start = region_start;
self.region_beg = region_beg;
self.region_end = region_end;
}
}
14 changes: 0 additions & 14 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ pub fn parse_u64(data: Option<String>) -> Option<u64> {
data
}

/// Convert two Option<64> to region tuple.
///
/// # Arguments
///
/// * `start` - Start region point.
/// * `end` - End region point.
pub fn to_region(start: Option<u64>, end: Option<u64>) -> Option<Region> {
if start.is_none() || end.is_none() {
None
} else {
Some(Region::new(start, end))
}
}

/// Wrapper to fs::read_to_string
///
/// # Arguments
Expand Down

0 comments on commit 6c1494c

Please sign in to comment.