Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Implement save for remote buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed May 15, 2018
1 parent cd10079 commit 406cfb9
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion xray_core/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ pub enum RpcRequest {
OpenBuffer {
buffer_id: BufferId,
},
SaveBuffer {
buffer_id: BufferId,
},
}

#[derive(Deserialize, Serialize)]
pub enum RpcResponse {
OpenedBuffer(Result<rpc::ServiceId, Error>),
SavedBuffer(Result<(), Error>),
}

pub struct PathSearch {
Expand Down Expand Up @@ -123,6 +127,7 @@ pub enum Error {
TreeNotFound,
IoError(String),
RpcError(rpc::Error),
UnexpectedResponse,
}

impl LocalProject {
Expand Down Expand Up @@ -334,6 +339,7 @@ impl Project for RemoteProject {
.map_err(|error| error.into())
})
}),
_ => Err(Error::UnexpectedResponse),
})
}),
)
Expand Down Expand Up @@ -363,13 +369,23 @@ impl Project for RemoteProject {
.map_err(|error| error.into())
})
}),
_ => Err(Error::UnexpectedResponse),
})
}),
)
}

fn save_buffer(&self, buffer_id: BufferId) -> Box<Future<Item = (), Error = Error>> {
unimplemented!()
Box::new(
self.service
.borrow()
.request(RpcRequest::SaveBuffer { buffer_id })
.map_err(|error| error.into())
.and_then(|response| match response {
RpcResponse::SavedBuffer(result) => result,
_ => Err(Error::UnexpectedResponse),
}),
)
}

fn search_paths(
Expand Down Expand Up @@ -472,6 +488,12 @@ impl rpc::server::Service for ProjectService {
},
)))
}
RpcRequest::SaveBuffer { buffer_id } => Some(Box::new(
self.project
.borrow()
.save_buffer(buffer_id)
.then(|result| Ok(RpcResponse::SavedBuffer(result))),
)),
}
}
}
Expand Down

0 comments on commit 406cfb9

Please sign in to comment.