mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-07-19 10:25:15 +00:00
add protobuf transport and refactor to support (#24)
This commit is contained in:
parent
b3e0ee7b6e
commit
643a47953e
21 changed files with 406 additions and 74 deletions
|
@ -1,4 +1,4 @@
|
|||
use djls_ipc::{parse_json_response, JsonResponse, PythonProcess, TransportError};
|
||||
use djls_ipc::{JsonResponse, PythonProcess, TransportError, TransportMessage, TransportResponse};
|
||||
use serde::Deserialize;
|
||||
use std::fmt;
|
||||
|
||||
|
@ -55,10 +55,18 @@ impl Apps {
|
|||
}
|
||||
|
||||
pub fn check_installed(python: &mut PythonProcess, app: &str) -> Result<bool, TransportError> {
|
||||
let response = python.send("installed_apps_check", Some(vec![app.to_string()]))?;
|
||||
let response = parse_json_response(response)?;
|
||||
let result = InstalledAppsCheck::try_from(response)?;
|
||||
Ok(result.has_app)
|
||||
let message = TransportMessage::Json("installed_apps_check".to_string());
|
||||
let response = python.send(message, Some(vec![app.to_string()]))?;
|
||||
match response {
|
||||
TransportResponse::Json(json_str) => {
|
||||
let json_response: JsonResponse = serde_json::from_str(&json_str)?;
|
||||
let result = InstalledAppsCheck::try_from(json_response)?;
|
||||
Ok(result.has_app)
|
||||
}
|
||||
_ => Err(TransportError::Process(
|
||||
"Unexpected response type".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::apps::Apps;
|
||||
use crate::gis::{check_gis_setup, GISError};
|
||||
use crate::templates::TemplateTags;
|
||||
use djls_ipc::{parse_json_response, JsonResponse, PythonProcess, TransportError};
|
||||
use djls_ipc::{JsonResponse, PythonProcess, TransportError, TransportMessage, TransportResponse};
|
||||
use djls_python::{ImportCheck, Python};
|
||||
use serde::Deserialize;
|
||||
use std::fmt;
|
||||
|
@ -23,9 +23,17 @@ struct DjangoSetup {
|
|||
|
||||
impl DjangoSetup {
|
||||
pub fn setup(python: &mut PythonProcess) -> Result<JsonResponse, ProjectError> {
|
||||
let response = python.send("django_setup", None)?;
|
||||
let response = parse_json_response(response)?;
|
||||
Ok(response)
|
||||
let message = TransportMessage::Json("django_setup".to_string());
|
||||
let response = python.send(message, None)?;
|
||||
match response {
|
||||
TransportResponse::Json(json_str) => {
|
||||
let json_response: JsonResponse = serde_json::from_str(&json_str)?;
|
||||
Ok(json_response)
|
||||
}
|
||||
_ => Err(ProjectError::Transport(TransportError::Process(
|
||||
"Unexpected response type".to_string(),
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue