style: apply cargo fmt across workspace

This commit is contained in:
Karim Jerbi committed 2026-10-11 03:14:29 +01:00
1 parent 85710e5454
commit 9cf9ff2c5c
531 files changed
+57740 -33906

No files matched your search

+80 -29
View File
@@ -16,7 +16,7 @@ use crate::ipc::protocol::{
HostResponse, HostToPlugin, PluginRequest, PluginResponse, PluginToHost, RunnerHandshake,
};
use crate::ipc::transport::{recv, send};
use crate::shm::{DocumentViewInfo, SharedDocumentReader, DocumentViewData};
use crate::shm::{DocumentViewData, DocumentViewInfo, SharedDocumentReader};
/// Shared registry of active interactive commands, keyed by host-assigned id.
pub type InteractiveRegistry = Rc<RefCell<HashMap<u64, Box<dyn InteractiveCommand>>>>;
@@ -60,7 +60,10 @@ impl IpcClient {
&self,
req: PluginRequest,
) -> Result<PluginResponse, crate::ipc::transport::TransportError> {
send(&mut self.stream.borrow_mut(), &PluginToHost::Request(Box::new(req)))?;
send(
&mut self.stream.borrow_mut(),
&PluginToHost::Request(Box::new(req)),
)?;
loop {
match recv::<HostToPlugin>(&mut self.stream.borrow_mut())? {
HostToPlugin::Response(resp) => return Ok(*resp),
@@ -389,16 +392,18 @@ impl HostApi for PluginHostApi {
}
}
match self.doc_view.borrow().as_ref() {
Some(info) => match SharedDocumentReader::<DocumentViewData>::open(Path::new(&info.path)) {
Ok(reader) => Box::new(reader),
Err(e) => {
eprintln!(
"[plugin] failed to open document view at {}: {e}",
info.path
);
Box::new(EmptyDocumentReader)
Some(info) => {
match SharedDocumentReader::<DocumentViewData>::open(Path::new(&info.path)) {
Ok(reader) => Box::new(reader),
Err(e) => {
eprintln!(
"[plugin] failed to open document view at {}: {e}",
info.path
);
Box::new(EmptyDocumentReader)
}
}
},
}
None => Box::new(EmptyDocumentReader),
}
}
@@ -419,7 +424,9 @@ impl HostApi for PluginHostApi {
}
fn system_variable(&self, name: &str) -> Option<HostSettingValue> {
match self.client.request(PluginRequest::GetSystemVariable { name: name.to_owned() }) {
match self.client.request(PluginRequest::GetSystemVariable {
name: name.to_owned(),
}) {
Ok(PluginResponse::SystemVariable(value)) => value,
_ => None,
}
@@ -451,11 +458,16 @@ impl HostApi for PluginHostApi {
label: &str,
entities: Vec<EntityType>,
) -> Result<(), String> {
match self.client.request(PluginRequest::UpdateEntitiesTransaction {
label: label.to_owned(), entities,
}) {
match self
.client
.request(PluginRequest::UpdateEntitiesTransaction {
label: label.to_owned(),
entities,
}) {
Ok(PluginResponse::EntityTransactionResult(result)) => {
if result.is_ok() { self.document_cache = OnceCell::new(); }
if result.is_ok() {
self.document_cache = OnceCell::new();
}
result
}
Ok(PluginResponse::Error(error)) => Err(error),
@@ -471,10 +483,18 @@ impl HostApi for PluginHostApi {
}
}
fn solid_operation(&mut self, operation: crate::host::SolidOperation) -> Result<Handle, String> {
match self.client.request(PluginRequest::SolidOperation { operation }) {
fn solid_operation(
&mut self,
operation: crate::host::SolidOperation,
) -> Result<Handle, String> {
match self
.client
.request(PluginRequest::SolidOperation { operation })
{
Ok(PluginResponse::SolidResult(result)) => {
if result.is_ok() { self.document_cache = OnceCell::new(); }
if result.is_ok() {
self.document_cache = OnceCell::new();
}
result
}
Ok(PluginResponse::Error(error)) => Err(error),
@@ -483,7 +503,10 @@ impl HostApi for PluginHostApi {
}
}
fn run_command(&mut self, request: crate::host::CommandRequest) -> Result<crate::host::CommandOutcome, String> {
fn run_command(
&mut self,
request: crate::host::CommandRequest,
) -> Result<crate::host::CommandOutcome, String> {
match self.client.request(PluginRequest::RunCommand { request }) {
Ok(PluginResponse::CommandResult(result)) => {
self.document_cache = OnceCell::new();
@@ -495,10 +518,18 @@ impl HostApi for PluginHostApi {
}
}
fn table_operation(&mut self, operation: crate::host::TableOperation) -> Result<Handle, String> {
match self.client.request(PluginRequest::TableOperation { operation }) {
fn table_operation(
&mut self,
operation: crate::host::TableOperation,
) -> Result<Handle, String> {
match self
.client
.request(PluginRequest::TableOperation { operation })
{
Ok(PluginResponse::TableResult(result)) => {
if result.is_ok() { self.document_cache = OnceCell::new(); }
if result.is_ok() {
self.document_cache = OnceCell::new();
}
result
}
Ok(PluginResponse::Error(error)) => Err(error),
@@ -508,7 +539,9 @@ impl HostApi for PluginHostApi {
}
fn set_selection(&mut self, handles: &[Handle]) -> Result<(), String> {
match self.client.request(PluginRequest::SetSelection { handles: handles.to_vec() }) {
match self.client.request(PluginRequest::SetSelection {
handles: handles.to_vec(),
}) {
Ok(PluginResponse::SelectionResult(result)) => result,
Ok(PluginResponse::Error(error)) => Err(error),
Ok(other) => Err(format!("unexpected selection response: {other:?}")),
@@ -555,7 +588,10 @@ impl HostApi for PluginHostApi {
}
fn execute_command(&mut self, cmd: &str) -> bool {
match self.client.request(PluginRequest::ExecuteCommand(cmd.to_string())) {
match self
.client
.request(PluginRequest::ExecuteCommand(cmd.to_string()))
{
Ok(PluginResponse::Bool(b)) => b,
Ok(other) => {
eprintln!("[plugin] unexpected ExecuteCommand response: {other:?}");
@@ -662,7 +698,11 @@ mod tests {
},
other => panic!("unexpected: {other:?}"),
}
send(&mut peer, &HostToPlugin::Response(Box::new(PluginResponse::Ok))).unwrap();
send(
&mut peer,
&HostToPlugin::Response(Box::new(PluginResponse::Ok)),
)
.unwrap();
});
api.push_info("hello host");
peer_handle.join().unwrap();
@@ -719,7 +759,10 @@ mod tests {
EntityType::Point(Point::new()),
]);
peer_handle.join().unwrap();
assert_eq!(handles, vec![Handle::new(10), Handle::new(11), Handle::new(12)]);
assert_eq!(
handles,
vec![Handle::new(10), Handle::new(11), Handle::new(12)]
);
}
#[test]
@@ -734,7 +777,11 @@ mod tests {
},
other => panic!("unexpected: {other:?}"),
}
send(&mut peer, &HostToPlugin::Response(Box::new(PluginResponse::Bool(true)))).unwrap();
send(
&mut peer,
&HostToPlugin::Response(Box::new(PluginResponse::Bool(true))),
)
.unwrap();
});
assert!(api.update_entity(EntityType::Point(Point::new())));
peer_handle.join().unwrap();
@@ -754,7 +801,11 @@ mod tests {
},
other => panic!("unexpected: {other:?}"),
}
send(&mut peer, &HostToPlugin::Response(Box::new(PluginResponse::Bool(true)))).unwrap();
send(
&mut peer,
&HostToPlugin::Response(Box::new(PluginResponse::Bool(true))),
)
.unwrap();
});
assert!(api.remove_entity(Handle::new(7)));
peer_handle.join().unwrap();