Skip to content

Commit

Permalink
Tidy dependencies in ipc crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Dec 5, 2024
1 parent 9950d87 commit 3430784
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 59 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ serde_json.workspace = true
typeshare.workspace = true
parking_lot.workspace = true

sos-net = { version = "0.16", path = "../net", features = ["account", "search", "files"] }
sos-sdk = { version = "0.16", path = "../sdk", features = ["account"] }
sos-protocol = { version = "0.16", path = "../protocol" }
sos-account-extras = { version = "0.16", path = "../account_extras", features = ["clipboard"] }

tokio = { version = "1", features = ["rt", "rt-multi-thread", "net", "macros", "io-util", "io-std", "sync"] }
tokio-stream = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/ipc/src/bindings/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include!(concat!(env!("OUT_DIR"), "/common.rs"));

use crate::{Error, Result};
use sos_net::protocol::local_transport::{LocalRequest, LocalResponse};
use sos_protocol::local_transport::{LocalRequest, LocalResponse};
use std::collections::HashMap;

impl From<LocalRequest> for WireLocalRequest {
Expand Down
2 changes: 1 addition & 1 deletion crates/ipc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use interprocess::local_socket::{tokio::prelude::*, GenericNamespaced};
use tokio_stream::StreamExt;
use tokio_util::codec::{Framed, LengthDelimitedCodec};

use sos_net::sdk::prelude::PublicIdentity;
use sos_protocol::{
constants::routes::v1::ACCOUNTS_LIST,
local_transport::{LocalRequest, LocalResponse},
NetworkError,
};
use sos_sdk::prelude::PublicIdentity;

/// Socket client for inter-process communication.
pub struct SocketClient {
Expand Down
12 changes: 2 additions & 10 deletions crates/ipc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,11 @@ pub enum Error {

/// Errors generated by the SDK library.
#[error(transparent)]
Sdk(#[from] sos_net::sdk::Error),

/// Errors generated by the networking library.
#[error(transparent)]
Net(#[from] sos_net::Error),

/// Errors generated by the account extras library.
#[error(transparent)]
AccountExtras(#[from] sos_account_extras::Error),
Sdk(#[from] sos_sdk::Error),

/// Errors generated by the protocol library.
#[error(transparent)]
Protocol(#[from] sos_net::protocol::Error),
Protocol(#[from] sos_protocol::Error),

/// Errors generated when a URI is invalid.
#[error(transparent)]
Expand Down
4 changes: 1 addition & 3 deletions crates/ipc/src/native_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ use crate::{Error, Result, SocketClient};
use futures_util::{SinkExt, StreamExt};
use http::StatusCode;
use once_cell::sync::Lazy;
use sos_net::sdk::{
logs::Logger, prelude::IPC_GUI_SOCKET_NAME, url::Url, Paths,
};
use sos_protocol::local_transport::{LocalRequest, LocalResponse};
use sos_sdk::{logs::Logger, prelude::IPC_GUI_SOCKET_NAME, url::Url, Paths};
use std::{io::ErrorKind, sync::Arc, time::Duration};
use tokio::{
sync::{mpsc, Mutex},
Expand Down
24 changes: 11 additions & 13 deletions crates/ipc/src/service/local_server/account.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use http::{Request, Response, StatusCode};
use hyper::body::Bytes;
use sos_net::{
protocol::{
server_helpers, Merge, SyncPacket, SyncStorage, WireEncodeDecode,
},
sdk::prelude::{Account, AccountSwitcher, Identity},
use sos_protocol::{
server_helpers, Merge, SyncPacket, SyncStorage, WireEncodeDecode,
};
use sos_sdk::prelude::{Account, AccountSwitcher, Identity};
use std::sync::Arc;
use tokio::sync::RwLock;

Expand All @@ -23,7 +21,7 @@ where
A: Account<Error = E, NetworkResult = R> + Sync + Send + 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand All @@ -47,7 +45,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down Expand Up @@ -79,7 +77,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand All @@ -98,7 +96,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand All @@ -117,7 +115,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down Expand Up @@ -156,7 +154,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand All @@ -175,7 +173,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down Expand Up @@ -214,7 +212,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down
9 changes: 4 additions & 5 deletions crates/ipc/src/service/local_server/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use http::{
Request, Response, StatusCode,
};
use serde::Serialize;
use sos_net::sdk::prelude::Address;

use sos_net::protocol::constants::{
use sos_protocol::constants::{
ENCODING_ZLIB, ENCODING_ZSTD, MIME_TYPE_JSON, MIME_TYPE_PROTOBUF,
X_SOS_ACCOUNT_ID,
};
use sos_sdk::prelude::Address;

use super::{Body, Incoming};

Expand Down Expand Up @@ -94,7 +93,7 @@ pub fn protobuf(body: Body) -> hyper::Result<Response<Body>> {
}

pub fn protobuf_compress(body: Body) -> hyper::Result<Response<Body>> {
use sos_net::protocol::compression::zlib;
use sos_protocol::compression::zlib;
let Ok(buf) = zlib::encode_all(body.as_slice()) else {
return internal_server_error("zlib::compress");
};
Expand All @@ -108,7 +107,7 @@ pub fn protobuf_compress(body: Body) -> hyper::Result<Response<Body>> {

/*
pub fn protobuf_zstd(body: Body) -> hyper::Result<Response<Body>> {
use sos_net::protocol::compression::zstd;
use sos_protocol::compression::zstd;
let Ok(buf) = zstd::encode_all(body.as_slice(), 20) else {
return internal_server_error("zstd::compress");
};
Expand Down
16 changes: 7 additions & 9 deletions crates/ipc/src/service/local_server/events.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use http::{Request, Response};
use hyper::body::Bytes;
use sos_net::{
protocol::{
server_helpers, DiffRequest, Merge, PatchRequest, ScanRequest,
SyncStorage, WireEncodeDecode,
},
sdk::prelude::{Account, AccountSwitcher, StorageEventLogs},
use sos_protocol::{
server_helpers, DiffRequest, Merge, PatchRequest, ScanRequest,
SyncStorage, WireEncodeDecode,
};
use sos_sdk::prelude::{Account, AccountSwitcher, StorageEventLogs};
use std::sync::Arc;
use tokio::sync::RwLock;

Expand All @@ -27,7 +25,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down Expand Up @@ -76,7 +74,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down Expand Up @@ -121,7 +119,7 @@ where
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down
17 changes: 7 additions & 10 deletions crates/ipc/src/service/local_server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use http::{Method, Request, Response, StatusCode};
use parking_lot::Mutex;
use sos_net::{
protocol::{
constants::routes::v1::{
ACCOUNTS_LIST, SYNC_ACCOUNT, SYNC_ACCOUNT_EVENTS,
SYNC_ACCOUNT_STATUS,
},
local_transport::{LocalRequest, LocalResponse},
Merge, SyncStorage,
use sos_protocol::{
constants::routes::v1::{
ACCOUNTS_LIST, SYNC_ACCOUNT, SYNC_ACCOUNT_EVENTS, SYNC_ACCOUNT_STATUS,
},
sdk::prelude::{Account, AccountSwitcher},
local_transport::{LocalRequest, LocalResponse},
Merge, SyncStorage,
};
use sos_sdk::prelude::{Account, AccountSwitcher};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;
use tower::service_fn;
Expand Down Expand Up @@ -67,7 +64,7 @@ impl LocalServer {
+ 'static,
R: 'static,
E: std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down
5 changes: 2 additions & 3 deletions crates/ipc/src/service/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::ServiceAppInfo;
use async_trait::async_trait;
use sos_net::sdk::account::{Account, AccountSwitcher};
use sos_sdk::account::{Account, AccountSwitcher};

use sos_protocol::{
local_transport::{LocalRequest, LocalResponse},
Expand Down Expand Up @@ -44,7 +43,7 @@ impl IpcService {
R: 'static,
E: std::error::Error
+ std::fmt::Debug
+ From<sos_net::sdk::Error>
+ From<sos_sdk::Error>
+ From<std::io::Error>
+ 'static,
{
Expand Down

0 comments on commit 3430784

Please sign in to comment.