Skip to content

Commit

Permalink
style: Use reexport strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 1, 2024
1 parent 036d3f9 commit 5690ccf
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 196 deletions.
28 changes: 4 additions & 24 deletions src/handler/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pub use crate::handler::room::*;

/// Addition and Deletion to the buffer.
pub mod update {
use crate::channel::*;
use crate::constant::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::buffer::*;

const METHOD: &str = "buffer::update";

Expand Down Expand Up @@ -69,16 +64,7 @@ pub mod update {
///
/// This will only sync the view.
pub mod sync {
use crate::channel::*;
use crate::client::*;
use crate::constant::*;
use crate::handler::room::*;
use crate::room::*;
use crate::user::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::buffer::*;

const METHOD: &str = "buffer::sync";

Expand Down Expand Up @@ -122,13 +108,7 @@ pub mod sync {
///
/// Only user who locked the file and admins can edit the file.
pub mod lock {
use crate::channel::*;
use crate::constant::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::buffer::*;

const METHOD: &str = "buffer::lock";

Expand Down
45 changes: 13 additions & 32 deletions src/handler/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pub use crate::channel::*;
pub use crate::constant::*;
pub use crate::handler::room::*;
pub use crate::room::*;
pub use crate::user::*;
pub use crate::util::*;
pub use serde_json::Value;
pub use std::sync::Arc;
pub use tokio::sync::Mutex;

/// Sync file
///
/// Replace the client's file with server file; sync file
/// can make user's lose his work!
pub mod sync {
use crate::channel::*;
use crate::constant::*;
use crate::handler::room::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::file::*;

const METHOD: &str = "file::sync";

Expand Down Expand Up @@ -61,15 +63,7 @@ pub mod sync {

/// Return a list of users in the file.
pub mod info {
use crate::channel::*;
use crate::client::*;
use crate::constant::*;
use crate::handler::room::*;
use crate::room::*;
use crate::user::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::file::*;

const METHOD: &str = "file::info";

Expand Down Expand Up @@ -145,14 +139,7 @@ pub mod info {

/// Say
pub mod say {
use crate::channel::*;
use crate::constant::*;
use crate::handler::room::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::file::*;

const METHOD: &str = "file::say";

Expand Down Expand Up @@ -192,13 +179,7 @@ pub mod say {
///
/// Only user who locked the file and admins can edit the file.
pub mod lock {
use crate::channel::*;
use crate::constant::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::file::*;

const METHOD: &str = "file::lock";

Expand Down
35 changes: 12 additions & 23 deletions src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
pub mod buffer;
pub mod file;
pub mod room;
pub mod util;

use crate::channel::*;
use crate::room::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
pub use crate::channel::*;
pub use crate::client::*;
pub use crate::constant::*;
pub use crate::room::*;
pub use crate::util::*;
pub use serde_json::Value;
pub use std::sync::Arc;
pub use tokio::sync::Mutex;

pub async fn handle(channel: &mut Channel, room: &Arc<Mutex<Room>>, json: &str) {
let v = serde_json::from_str(json);
Expand Down Expand Up @@ -56,11 +60,7 @@ pub async fn handle(channel: &mut Channel, room: &Arc<Mutex<Room>>, json: &str)

/// Test
mod test {
use crate::channel::*;
use crate::room::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::*;

const METHOD: &str = "test";

Expand All @@ -85,12 +85,8 @@ mod test {

/// Ping pong
mod ping {
use crate::channel::*;
use crate::room::*;
use crate::handler::*;
use chrono;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;

const METHOD: &str = "pong";

Expand All @@ -106,14 +102,7 @@ mod ping {

/// Initialize for client that has first connected.
mod init {
use crate::channel::*;
use crate::client::*;
use crate::constant::*;
use crate::room::*;
use crate::util::*;
use serde_json::Value;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::handler::*;

const METHOD: &str = "init";

Expand Down
Loading

0 comments on commit 5690ccf

Please sign in to comment.