diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 55f187da..a29e4439 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -70,7 +70,7 @@ pub fn serve(options: &ServeOptions) -> Result<(), ServeError> { let patch_set = compute_patch_set(&snapshot, &tree, root_id); apply_patch_set(&mut tree, &patch_set); - let session = Arc::new(ServeSession::new(tree, maybe_project)); + let session = Arc::new(ServeSession::new(imfs, tree, maybe_project)); let server = LiveServer::new(session); server.start(port); diff --git a/src/serve_session.rs b/src/serve_session.rs index 8d132261..4f4d4e23 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -1,19 +1,24 @@ use std::collections::HashSet; use crate::{ - message_queue::MessageQueue, project::Project, session_id::SessionId, snapshot::RojoTree, + imfs::new::{Imfs, ImfsFetcher}, + message_queue::MessageQueue, + project::Project, + session_id::SessionId, + snapshot::RojoTree, }; /// Contains all of the state for a Rojo serve session. -pub struct ServeSession { +pub struct ServeSession { root_project: Option, session_id: SessionId, tree: RojoTree, message_queue: MessageQueue<()>, // TODO: Real message type + imfs: Imfs, } -impl ServeSession { - pub fn new(tree: RojoTree, root_project: Option) -> ServeSession { +impl ServeSession { + pub fn new(imfs: Imfs, tree: RojoTree, root_project: Option) -> Self { let session_id = SessionId::new(); let message_queue = MessageQueue::new(); @@ -22,6 +27,7 @@ impl ServeSession { root_project, tree, message_queue, + imfs, } } diff --git a/src/web/api.rs b/src/web/api.rs index 63f46d34..4bb6eedd 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -9,6 +9,7 @@ use hyper::{header, service::Service, Body, Method, Request, Response, StatusCod use rbx_dom_weak::RbxId; use crate::{ + imfs::new::ImfsFetcher, serve_session::ServeSession, web::{ interface::{ @@ -19,11 +20,11 @@ use crate::{ }, }; -pub struct ApiService { - serve_session: Arc, +pub struct ApiService { + serve_session: Arc>, } -impl Service for ApiService { +impl Service for ApiService { type ReqBody = Body; type ResBody = Body; type Error = hyper::Error; @@ -42,13 +43,13 @@ impl Service for ApiService { } } -impl ApiService { - pub fn new(serve_session: Arc) -> ApiService { +impl ApiService { + pub fn new(serve_session: Arc>) -> Self { ApiService { serve_session } } /// Get a summary of information about the server - fn handle_api_rojo(&self) -> ::Future { + fn handle_api_rojo(&self) -> ::Future { let tree = self.serve_session.tree(); let root_instance_id = tree.get_root_id(); @@ -63,7 +64,7 @@ impl ApiService { /// Retrieve any messages past the given cursor index, and if /// there weren't any, subscribe to receive any new messages. - fn handle_api_subscribe(&self, request: Request) -> ::Future { + fn handle_api_subscribe(&self, request: Request) -> ::Future { let argument = &request.uri().path()["/api/subscribe/".len()..]; let _input_cursor: u32 = match argument.parse() { Ok(v) => v, @@ -93,7 +94,7 @@ impl ApiService { // }) } - fn handle_api_read(&self, request: Request) -> ::Future { + fn handle_api_read(&self, request: Request) -> ::Future { let argument = &request.uri().path()["/api/read/".len()..]; let requested_ids: Option> = argument.split(',').map(RbxId::parse_str).collect(); diff --git a/src/web/mod.rs b/src/web/mod.rs index 05d55746..10bcc637 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -12,16 +12,16 @@ use futures::{ use hyper::{service::Service, Body, Request, Response, Server}; use log::trace; -use crate::serve_session::ServeSession; +use crate::{imfs::new::ImfsFetcher, serve_session::ServeSession}; use self::{api::ApiService, ui::UiService}; -pub struct RootService { - api: ApiService, - ui: UiService, +pub struct RootService { + api: ApiService, + ui: UiService, } -impl Service for RootService { +impl Service for RootService { type ReqBody = Body; type ResBody = Body; type Error = hyper::Error; @@ -38,8 +38,8 @@ impl Service for RootService { } } -impl RootService { - pub fn new(serve_session: Arc) -> RootService { +impl RootService { + pub fn new(serve_session: Arc>) -> Self { RootService { api: ApiService::new(Arc::clone(&serve_session)), ui: UiService::new(Arc::clone(&serve_session)), @@ -47,12 +47,12 @@ impl RootService { } } -pub struct LiveServer { - serve_session: Arc, +pub struct LiveServer { + serve_session: Arc>, } -impl LiveServer { - pub fn new(serve_session: Arc) -> LiveServer { +impl LiveServer { + pub fn new(serve_session: Arc>) -> Self { LiveServer { serve_session } } diff --git a/src/web/ui.rs b/src/web/ui.rs index 4212f21a..9d66efa1 100644 --- a/src/web/ui.rs +++ b/src/web/ui.rs @@ -7,6 +7,7 @@ use hyper::{header, service::Service, Body, Method, Request, Response, StatusCod use ritz::html; use crate::{ + imfs::new::ImfsFetcher, serve_session::ServeSession, web::{ interface::{NotFoundError, SERVER_VERSION}, @@ -16,12 +17,12 @@ use crate::{ static HOME_CSS: &str = include_str!("../../assets/index.css"); -pub struct UiService { +pub struct UiService { #[allow(unused)] // TODO: Fill out interface service - serve_session: Arc, + serve_session: Arc>, } -impl Service for UiService { +impl Service for UiService { type ReqBody = Body; type ResBody = Body; type Error = hyper::Error; @@ -39,8 +40,8 @@ impl Service for UiService { } } -impl UiService { - pub fn new(serve_session: Arc) -> UiService { +impl UiService { + pub fn new(serve_session: Arc>) -> Self { UiService { serve_session } }