Skip to content

Commit

Permalink
rust crates refactoring
Browse files Browse the repository at this point in the history
ypopovych committed Jan 29, 2024
1 parent 826db1b commit 86214b8
Showing 51 changed files with 267 additions and 234 deletions.
34 changes: 22 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
[workspace]
resolver = "2"

members = [
"Rust/tesseract",
"Rust/transports",
"Rust/utils"
]
members = [ "Rust/sdk", "Rust/transport", "Rust/utils", "Rust/framework" ]

[workspace.package]
authors = ["Tesseract Systems, Inc. <info@tesseract.one>"]
authors = ["Daniel Leping", "Yehor Popovych", "Tesseract Systems, Inc."]
edition = "2021"
version = "0.1.0"
version = "0.5.6"
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/tesseract-one/Tesseract.swift"
documentation = "https://github.com/tesseract-one/Tesseract.swift"
homepage = "https://github.com/tesseract-one/"
categories = ["api-bindings", "authentication", "network-programming"]
keywords = ["blockchain", "dApp", "wallet", "mobile", "bridge"]

[workspace.dependencies]
async-trait = "0.1"
cbindgen = "0.26"
errorcon = "0.1"
log = "0.4"
tesseract = { git = "https://github.com/tesseract-one/Tesseract.rs.git", branch = "master" }
tesseract-protocol-test = { git = "https://github.com/tesseract-one/Tesseract.rs.git", branch = "master" }
tesseract-protocol-substrate = { git = "https://github.com/tesseract-one/Tesseract.rs.git", branch = "master" }

#build deps (C-interop)
cbindgen = "0.26"

#tesseract
tesseract-one = "0.5"

#protocols
tesseract-protocol-test = "0.5"
tesseract-protocol-substrate = "0.5"

#local
tesseract-swift-utils = { path = "Rust/utils", version = "0.5.6"}
tesseract-swift-transport = { path = "Rust/transport", version = "0.5.6"}
tesseract-swift = { path = "Rust/sdk", version = "0.5.6"}

[profile.release]
strip = true
14 changes: 5 additions & 9 deletions Examples/Rust/Rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
[workspace]

resolver = "2"

members = [
"app",
"wallet"
]

[workspace.dependencies]
tesseract = { git = "https://github.com/tesseract-one/Tesseract.rs.git", branch = "dapp-fixes" }
tesseract-protocol-test = { git = "https://github.com/tesseract-one/Tesseract.rs.git", branch = "dapp-fixes" }
#tesseract = { path = "../../../../Tesseract.rs/tesseract", features = ["client"] }
#tesseract-protocol-test = { path = "../../../../Tesseract.rs/protocols/test", features = ["client"] }
tesseract-one = "0.5"
tesseract-protocol-test = "0.5"

tesseract-swift = { path = "../../../Rust/sdk" }

tesseract-swift-utils = { path = "../../../Rust/utils" }
tesseract-swift-transports = { path = "../../../Rust/transports" }
async-trait = "0.1"
errorcon = "0.1"
log = "0.4"
log-panics = { version = "2", features = ["with-backtrace"]}
log-panics = { version = "2", features = ["with-backtrace"] }
stderrlog = "0.5"
cbindgen = "0.26"

9 changes: 4 additions & 5 deletions Examples/Rust/Rust/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,16 +3,15 @@ name = "app"
version = "0.0.1"
authors = ["Tesseract Systems, Inc. <info@tesseract.one>"]
license = "Apache-2.0"
description = "Cardano bindings for C."
keywords = [ "Tesseract", "Cardano", "C" ]
description = "Tesseract SDK Client Example"
edition = "2021"

[dependencies]
tesseract-swift-utils.workspace = true
tesseract-swift-transports = { workspace = true, features = ["client"]}
tesseract-swift = { workspace = true, features = ["client"] }

tesseract = { workspace = true, features = ["client"] }
tesseract-one = { workspace = true, features = ["client"] }
tesseract-protocol-test = { workspace = true, features = ["client"] }

async-trait.workspace = true
errorcon.workspace = true
log.workspace = true
2 changes: 1 addition & 1 deletion Examples/Rust/Rust/app/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ prefix_with_name = true

[parse]
parse_deps = true
include = ["tesseract-swift-utils", "tesseract-swift-client"]
include = ["tesseract-swift", "tesseract-swift-utils", "tesseract-swift-transport"]

[export]
exclude = [
4 changes: 2 additions & 2 deletions Examples/Rust/Rust/app/src/delegate.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ use std::{collections::HashMap, sync::Arc};

use async_trait::async_trait;

use tesseract::client::{transport::Status, Delegate};
use tesseract_swift_utils::{ptr::CAnyDropPtr, string::CString, string::CStringRef, traits::AsCRef};
use tesseract_one::client::{transport::Status, Delegate};
use tesseract_swift::utils::{ptr::CAnyDropPtr, string::CString, string::CStringRef, traits::AsCRef};

#[repr(C)]
pub struct AlertProvider {
26 changes: 8 additions & 18 deletions Examples/Rust/Rust/app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
#![feature(async_closure)]

extern crate async_trait;
extern crate tesseract;
extern crate tesseract_protocol_test;
extern crate tesseract_swift_transports;
extern crate tesseract_swift_utils;
extern crate errorcon;

pub mod delegate;

use delegate::{AlertProvider, TransportDelegate};
use stderrlog::LogLevelNum;
use tesseract::client::Tesseract;
use tesseract_one::client::Tesseract;
use errorcon::convertible::ErrorContext;

pub use tesseract_swift_transports::client::*;
use tesseract_protocol_test::TestService;
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::future_impls::CFutureString;
use tesseract_swift_utils::response::CMoveResponse;
use tesseract_swift_utils::string::CStringRef;
use tesseract_swift_utils::traits::TryAsRef;
use tesseract_swift_utils::ptr::SyncPtr;
use tesseract_swift_utils::error::CError;
pub use tesseract_swift_utils::*;
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::client::transport::ClientTransport;
use tesseract_swift::utils::{
future_impls::CFutureString, response::CMoveResponse, string::CStringRef,
traits::TryAsRef, ptr::SyncPtr, error::CError, Void
};

use std::mem::ManuallyDrop;
use std::sync::Arc;
@@ -46,7 +36,7 @@ impl AppContextPtr {
}

struct AppContext {
service: Arc<dyn tesseract::client::Service<Protocol = tesseract_protocol_test::Test>>,
service: Arc<dyn tesseract_one::client::Service<Protocol = tesseract_protocol_test::Test>>,
}

#[no_mangle]
10 changes: 5 additions & 5 deletions Examples/Rust/Rust/wallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@ name = "wallet"
version = "0.0.1"
authors = ["Tesseract Systems, Inc. <info@tesseract.one>"]
license = "Apache-2.0"
description = "Cardano bindings for C."
keywords = [ "Tesseract", "Cardano", "C" ]
description = "Tesseract SDK Service Example"
edition = "2021"

[dependencies]
tesseract-swift-utils.workspace = true
tesseract-swift-transports = { workspace = true, features = ["service"]}
tesseract = { workspace = true, features = ["service"] }
tesseract-swift = { workspace = true, features = ["service"] }

tesseract-one = { workspace = true, features = ["service"] }
tesseract-protocol-test = { workspace = true, features = ["service"] }

async-trait.workspace = true
errorcon.workspace = true
log.workspace = true
2 changes: 1 addition & 1 deletion Examples/Rust/Rust/wallet/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ prefix_with_name = true

[parse]
parse_deps = true
include = ["tesseract-swift-utils", "tesseract-swift-service"]
include = ["tesseract-swift", "tesseract-swift-utils", "tesseract-swift-transport"]

[export]
exclude = [
2 changes: 1 addition & 1 deletion Examples/Rust/Rust/wallet/src/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::atomic::{AtomicBool, Ordering};
use stderrlog::LogLevelNum;
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift::error::TesseractSwiftError;

static INITIALIZED: AtomicBool = AtomicBool::new(false);

35 changes: 13 additions & 22 deletions Examples/Rust/Rust/wallet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
#![feature(async_closure)]

extern crate async_trait;
extern crate errorcon;
extern crate tesseract;
extern crate tesseract_protocol_test;
extern crate tesseract_swift_transports;
extern crate tesseract_swift_utils;

use async_trait::async_trait;
use errorcon::convertible::ErrorContext;
use stderrlog::LogLevelNum;
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift::error::TesseractSwiftError;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use tesseract::service::Tesseract;
use tesseract_swift_transports::service::ServiceTransport;
use tesseract_swift_utils::error::CError;
use tesseract_swift_utils::future_impls::CFutureBool;
use tesseract_swift_utils::ptr::{CAnyDropPtr, SyncPtr};
use tesseract_swift_utils::response::CMoveResponse;
use tesseract_swift_utils::string::{CString, CStringRef};
use tesseract_swift_utils::traits::{TryAsRef, AsCRef};
use tesseract_swift_utils::Void;
use tesseract_one::service::Tesseract;
use tesseract_swift::service::transport::ServiceTransport;
use tesseract_swift::utils::{
error::CError, future_impls::CFutureBool, ptr::{CAnyDropPtr, SyncPtr},
response::CMoveResponse, string::{CString, CStringRef}, traits::{TryAsRef, AsCRef},
Void
};

mod init;

@@ -55,21 +46,21 @@ impl TestService {
}
}

impl tesseract::service::Service for TestService {
impl tesseract_one::service::Service for TestService {
type Protocol = tesseract_protocol_test::Test;

fn protocol(&self) -> &tesseract_protocol_test::Test {
&tesseract_protocol_test::Test::Protocol
}

fn to_executor(self) -> Box<dyn tesseract::service::Executor + Send + Sync> {
fn to_executor(self) -> Box<dyn tesseract_one::service::Executor + Send + Sync> {
Box::new(tesseract_protocol_test::service::TestExecutor::from_service(self))
}
}

#[async_trait]
impl tesseract_protocol_test::TestService for TestService {
async fn sign_transaction(self: Arc<Self>, req: &str) -> tesseract::Result<String> {
async fn sign_transaction(self: Arc<Self>, req: &str) -> tesseract_one::Result<String> {
let cstr: CString = req.into();
let future = unsafe {
ManuallyDrop::into_inner((self.ui.approve_tx)(&self.ui, cstr.as_cref()))
@@ -79,12 +70,12 @@ impl tesseract_protocol_test::TestService for TestService {

if allow {
if req == "make_error" {
Err(tesseract::Error::described(tesseract::ErrorKind::Weird, "intentional error for test").into())
Err(tesseract_one::Error::described(tesseract_one::ErrorKind::Weird, "intentional error for test").into())
} else {
Ok(format!("{}{}", req, self.signature))
}
} else {
Err(tesseract::Error::kinded(tesseract::ErrorKind::Cancelled).into())
Err(tesseract_one::Error::kinded(tesseract_one::ErrorKind::Cancelled).into())
}
}).await
}
44 changes: 44 additions & 0 deletions Rust/framework/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "tesseract-swift-framework"
description = "Tesseract framework to be embedded into prebuilt Swift artifacts. Don't use directly."
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
documentation.workspace = true
readme.workspace = true
authors.workspace = true
categories.workspace = true
keywords.workspace = true

[dependencies]
async-trait.workspace = true
errorcon.workspace = true
log.workspace = true

log-panics = { version = "2", features = ["with-backtrace"] }
stderrlog = "0.5"

tesseract-swift.workspace = true

tesseract-one.workspace = true
tesseract-protocol-test = { workspace = true, optional = true, features = ["client", "service"] }
tesseract-protocol-substrate = { workspace = true, optional = true, features = ["client", "service"] }

[build-dependencies]
cbindgen.workspace = true

[features]
default = ["client", "service", "protocol-all"]

client = ["tesseract-swift/client", "tesseract-one/client"]
service = ["tesseract-swift/service", "tesseract-one/service"]

protocol-test = ["dep:tesseract-protocol-test"]
protocol-substrate = ["dep:tesseract-protocol-substrate"]
protocol-all = ["protocol-test", "protocol-substrate"]

[lib]
crate-type = ["staticlib"]

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ prefix_with_name = true

[parse]
parse_deps = true
include = ["tesseract-swift-utils", "tesseract-swift-transports"]
include = ["tesseract-swift", "tesseract-swift-utils", "tesseract-swift-transport"]

[export]
exclude = [
20 changes: 9 additions & 11 deletions Rust/tesseract/src/client.rs → Rust/framework/src/client.rs
Original file line number Diff line number Diff line change
@@ -2,17 +2,15 @@ use std::sync::Arc;
use std::{mem::ManuallyDrop, collections::HashMap};

use async_trait::async_trait;
use tesseract::Protocol;
use tesseract::client::{Transport, Tesseract, Service, Delegate, transport,};
use tesseract::serialize::Serializer as TSerializer;
use tesseract_swift_transports::client::{ClientTransport, ClientStatus};
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::array::CArray;
use tesseract_swift_utils::future_impls::CFutureString;
use tesseract_swift_utils::traits::AsCRef;
use tesseract_swift_utils::{
ptr::{SyncPtr, CAnyDropPtr}, Void, array::CArrayRef,
map::CKeyValue, string::CString
use tesseract_one::Protocol;
use tesseract_one::client::{Transport, Tesseract, Service, Delegate, transport};
use tesseract_one::serialize::Serializer as TSerializer;

use tesseract_swift::client::transport::{ClientTransport, ClientStatus};
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{
array::{CArray, CArrayRef}, future_impls::CFutureString, traits::AsCRef,
ptr::{SyncPtr, CAnyDropPtr}, map::CKeyValue, string::CString, Void
};

pub type ClientTransportsStatusRef<'a> = CArrayRef<'a, CKeyValue<CString, ClientStatus>>;
5 changes: 3 additions & 2 deletions Rust/tesseract/src/init.rs → Rust/framework/src/init.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::mem::ManuallyDrop;
use errorcon::convertible::ErrorContext;
use stderrlog::LogLevelNum;
use tesseract_swift_utils::{response::CVoidResponse, error::CError};
use tesseract_swift_transports::error::TesseractSwiftError;

use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{response::CVoidResponse, error::CError};

#[repr(C)]
pub enum LogLevel {
4 changes: 0 additions & 4 deletions Rust/tesseract/src/lib.rs → Rust/framework/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#![feature(async_closure)]

extern crate errorcon;
extern crate tesseract_swift_utils;
extern crate tesseract_swift_transports;

#[cfg(feature = "client")]
pub mod client;

5 changes: 5 additions & 0 deletions Rust/framework/src/protocols/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[cfg(feature = "protocol-test")]
pub mod test;

#[cfg(feature="protocol-substrate")]
pub mod substrate;
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@ use crate::client::ClientTesseract;
use super::{SubstrateService, SubstrateAccountType, SubstrateGetAccountResponse};
use errorcon::convertible::ErrorContext;
use tesseract_protocol_substrate::{Substrate, SubstrateService as TSubstrateService};
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::{
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{
string::CStringRef, future_impls::CFutureData, ptr::CAnyDropPtr, future::CFuture, data::CDataRef, traits::TryAsRef
};

pub type Service = Arc<dyn tesseract::client::Service<Protocol = Substrate>>;
pub type Service = Arc<dyn tesseract_one::client::Service<Protocol = Substrate>>;

#[no_mangle]
pub extern "C" fn tesseract_client_get_substrate_service(
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use tesseract_protocol_substrate::{AccountType, GetAccountResponse};
use tesseract_swift_transports::protocol::TesseractProtocol;
use tesseract_swift_utils::{

use tesseract_swift::protocol::TesseractProtocol;
use tesseract_swift::utils::{
data::{CData, CDataRef}, string::{CString, CStringRef},
error::CError, ptr::CAnyDropPtr, future::CFuture, future_impls::CFutureData
};
use std::mem::ManuallyDrop;

#[cfg(feature="protocol-substrate-client")]
#[cfg(feature="client")]
pub mod client;

#[cfg(feature="protocol-substrate-service")]
#[cfg(feature="service")]
pub mod service;

#[repr(C)]
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ use std::{mem::ManuallyDrop, sync::Arc};

use async_trait::async_trait;
use errorcon::convertible::ErrorContext;
use tesseract::service::{Service, Executor};
use tesseract_one::service::{Service, Executor};
use tesseract_protocol_substrate::{service::SubstrateExecutor, AccountType, GetAccountResponse};
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::{string:: CString, traits::AsCRef};
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{string:: CString, traits::AsCRef};

use crate::service::ServiceTesseract;

@@ -25,7 +25,7 @@ impl Service for SubstrateService {

#[async_trait]
impl tesseract_protocol_substrate::SubstrateService for SubstrateService {
async fn get_account(self: Arc<Self>, account_type: AccountType) -> tesseract::Result<GetAccountResponse> {
async fn get_account(self: Arc<Self>, account_type: AccountType) -> tesseract_one::Result<GetAccountResponse> {
let future = unsafe {
ManuallyDrop::into_inner((self.get_account)(&self, account_type.into()))
};
@@ -41,7 +41,7 @@ impl tesseract_protocol_substrate::SubstrateService for SubstrateService {
extrinsic_data: &[u8],
extrinsic_metadata: &[u8],
extrinsic_types: &[u8],
) -> tesseract::Result<Vec<u8>> {
) -> tesseract_one::Result<Vec<u8>> {
let cpath: CString = account_path.into();
let future = unsafe {
(self.sign_transaction)(
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@ use crate::client::ClientTesseract;
use super::TestService;
use errorcon::convertible::ErrorContext;
use tesseract_protocol_test::{Test, TestService as TTestService};
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::{string::CStringRef, future_impls::CFutureString, ptr::CAnyDropPtr, traits::TryAsRef};
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{string::CStringRef, future_impls::CFutureString, ptr::CAnyDropPtr, traits::TryAsRef};

pub type Service = Arc<dyn tesseract::client::Service<Protocol = Test>>;
pub type Service = Arc<dyn tesseract_one::client::Service<Protocol = Test>>;

#[no_mangle]
pub extern "C" fn tesseract_client_get_test_service(
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#[cfg(feature="protocol-test-client")]
#[cfg(feature="client")]
pub mod client;

#[cfg(feature="protocol-test-service")]
#[cfg(feature="service")]
pub mod service;

use std::mem::ManuallyDrop;
use tesseract_swift_transports::protocol::TesseractProtocol;
use tesseract_swift_utils::string::CStringRef;
use tesseract_swift_utils::{ptr::CAnyDropPtr, future_impls::CFutureString};
use tesseract_swift::protocol::TesseractProtocol;
use tesseract_swift::utils::{ptr::CAnyDropPtr, string::CStringRef, future_impls::CFutureString};

#[repr(C)]
pub struct TestService {
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use async_trait::async_trait;
use errorcon::convertible::ErrorContext;
use tesseract::service::{Executor, Service};
use tesseract_one::service::{Executor, Service};
use tesseract_protocol_test::service::TestExecutor;
use tesseract_swift_transports::error::TesseractSwiftError;
use tesseract_swift_utils::string::CString;
use tesseract_swift_utils::traits::AsCRef;
use tesseract_swift::error::TesseractSwiftError;
use tesseract_swift::utils::{string::CString, traits::AsCRef};

use super::TestService;
use crate::service::ServiceTesseract;
@@ -26,7 +25,7 @@ impl Service for TestService {

#[async_trait]
impl tesseract_protocol_test::TestService for TestService {
async fn sign_transaction(self: Arc<Self>, req: &str) -> tesseract::Result<String> {
async fn sign_transaction(self: Arc<Self>, req: &str) -> tesseract_one::Result<String> {
let cstr: CString = req.into();
let future = unsafe {
ManuallyDrop::into_inner((self.sign_transaction)(&self, cstr.as_cref()))
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use tesseract::service::{Tesseract, Service, Transport};
use tesseract_swift_utils::ptr::SyncPtr;
use tesseract_swift_utils::Void;
use tesseract_swift_transports::service::ServiceTransport;
use tesseract_one::service::{Tesseract, Service, Transport};

use tesseract_swift::service::transport::ServiceTransport;
use tesseract_swift::utils::{ptr::SyncPtr, Void};

use std::mem::ManuallyDrop;

2 changes: 1 addition & 1 deletion Rust/generate_headers.sh
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
set -e

MODULE_NAME="CTesseractShared"
MAIN_CRATE="tesseract-swift-transports"
MAIN_CRATE="tesseract-swift-transport"
HEADERS_DIR="target/release/include"
OUTPUT_DIR="Sources/$MODULE_NAME/include"

6 changes: 2 additions & 4 deletions Rust/generate_xcframework.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/zsh
set -e

CRATE="tesseract-swift"
CRATE="tesseract-swift-framework"
XCFRAMEWORK_NAME="CTesseract"

DIR="$(cd "$(dirname "$0")" && pwd -P)"
SOURCES_DIR="${DIR}/.."
@@ -142,9 +143,6 @@ else
CONFIGURATION="release"
fi

# generate name for xcframework
XCFRAMEWORK_NAME="C${${${(C)CRATE}//-}//Swift}"

# output xcframework path
XCFRAMEWORK_PATH="${OUTPUT_DIR}/${XCFRAMEWORK_NAME}.xcframework"

24 changes: 24 additions & 0 deletions Rust/sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "tesseract-swift"
description = "Swift specific Tesseract APIs"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
documentation.workspace = true
readme.workspace = true
authors.workspace = true
categories.workspace = true
keywords.workspace = true

[dependencies]
tesseract-swift-utils.workspace = true
tesseract-swift-transport.workspace = true

[features]
default = ["transport-all"]
client = ["tesseract-swift-transport/client"]
service = ["tesseract-swift-transport/service"]
transport-sdk = []
transport-all = ["transport-sdk"]
4 changes: 4 additions & 0 deletions Rust/sdk/src/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[cfg(feature = "transport-sdk")]
pub mod transport {
pub use tesseract_swift_transport::client::*;
}
17 changes: 17 additions & 0 deletions Rust/sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pub mod error {
pub use tesseract_swift_transport::error::TesseractSwiftError;
}

pub mod protocol {
pub use tesseract_swift_transport::protocol::TesseractProtocol;
}

pub mod utils {
pub use tesseract_swift_utils::*;
}

#[cfg(feature = "client")]
pub mod client;

#[cfg(feature = "service")]
pub mod service;
4 changes: 4 additions & 0 deletions Rust/sdk/src/service.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[cfg(feature = "transport-sdk")]
pub mod transport {
pub use tesseract_swift_transport::service::*;
}
39 changes: 0 additions & 39 deletions Rust/tesseract/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions Rust/tesseract/src/protocols/mod.rs

This file was deleted.

30 changes: 30 additions & 0 deletions Rust/transport/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "tesseract-swift-transport"
description = "Crate with transport related Tesseract APIs for Swift"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
documentation.workspace = true
readme.workspace = true
authors.workspace = true
categories.workspace = true
keywords.workspace = true

[dependencies]
thiserror = "1.0"

async-trait.workspace = true
errorcon.workspace = true
log.workspace = true

tesseract-one.workspace = true
tesseract-swift-utils.workspace = true

[features]
client = ["tesseract-one/client"]
service = ["tesseract-one/service"]

[build-dependencies]
cbindgen.workspace = true
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ use tesseract_swift_utils::traits::{AsCRef, TryAsRef};
use async_trait::async_trait;
use errorcon::convertible::ErrorContext;

use tesseract::client::Connection;
use tesseract::Result;
use tesseract_one::client::Connection;
use tesseract_one::Result;

#[repr(C)]
pub struct ClientConnection {
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use tesseract_swift_utils::error::CError;
use tesseract_swift_utils::future::CFuture;
use tesseract_swift_utils::string::CString;

use tesseract::client::transport::Status;
use tesseract_one::client::transport::Status;

use crate::error::TesseractSwiftError;

Original file line number Diff line number Diff line change
@@ -11,10 +11,10 @@ use tesseract_swift_utils::string::CString;
use async_trait::async_trait;
use errorcon::convertible::ErrorContext;

use tesseract::client::transport::Status;
use tesseract::client::Connection;
use tesseract::client::Transport;
use tesseract::Protocol;
use tesseract_one::client::transport::Status;
use tesseract_one::client::Connection;
use tesseract_one::client::Transport;
use tesseract_one::Protocol;

#[repr(C)]
pub struct ClientTransport {
@@ -60,7 +60,7 @@ impl Transport for ClientTransport {
let future = unsafe {
ManuallyDrop::into_inner((self.status)(self.as_ref(), ManuallyDrop::new(proto)))
};
let result: Result<Status, tesseract::Error> = TesseractSwiftError::context_async(async || {
let result: Result<Status, tesseract_one::Error> = TesseractSwiftError::context_async(async || {
let status = future.try_into_future()?.await?;
Ok(status.into())
}).await;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem::ManuallyDrop;
use thiserror;
use tesseract::{Error as TError, ErrorKind};
use tesseract_one::{Error as TError, ErrorKind};
use tesseract_swift_utils::{error::{CError, CErrorCode, ErrorCode, SwiftError},
traits::TryAsRef, string::CString};

12 changes: 12 additions & 0 deletions Rust/transport/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(async_closure)]

pub mod error;
pub mod protocol;
pub use tesseract_swift_utils as utils;

#[cfg(feature = "client")]
pub mod client;

#[cfg(feature = "service")]
pub mod service;

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::mem::ManuallyDrop;

use tesseract::Protocol;
use tesseract_swift_utils::{string::CString, ptr::SyncPtr, Void};
use tesseract_one::Protocol;
use crate::utils::{string::CString, ptr::SyncPtr, Void};

#[repr(C)]
pub struct TesseractProtocol(SyncPtr<Void>);
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use tesseract_swift_utils::future_impls::CFutureData;
use tesseract_swift_utils::ptr::SyncPtr;
use tesseract_swift_utils::Void;

use tesseract::service::TransportProcessor;
use tesseract_one::service::TransportProcessor;

#[repr(C)]
pub struct ServiceTransportProcessor(SyncPtr<Void>);
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use std::mem::ManuallyDrop;
use std::sync::Arc;
use tesseract_swift_utils::ptr::CAnyDropPtr;

use tesseract::service::{BoundTransport, Transport, TransportProcessor};
use tesseract_one::service::{BoundTransport, Transport, TransportProcessor};

#[repr(transparent)]
pub struct ServiceBoundTransport(CAnyDropPtr);
25 changes: 0 additions & 25 deletions Rust/transports/Cargo.toml

This file was deleted.

16 changes: 0 additions & 16 deletions Rust/transports/src/lib.rs

This file was deleted.

11 changes: 7 additions & 4 deletions Rust/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "tesseract-swift-utils"
authors.workspace = true
description = "Tesseract interop helpers for Swift. Check tesseract-swift crate for full SDK."
version.workspace = true
license.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
documentation.workspace = true
description = "Tesseract interop helpers for Swift."
keywords = [ "Tesseract", "Swift", "C" ]
readme.workspace = true
authors.workspace = true
categories.workspace = true
keywords.workspace = true

[dependencies]
log.workspace = true
3 changes: 0 additions & 3 deletions Rust/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(return_position_impl_trait_in_trait)]
#![feature(async_closure)]

pub mod array;
@@ -16,8 +15,6 @@ pub mod string;
pub mod traits;
pub mod map;

#[cfg(feature = "bigint")]
extern crate num_bigint;
#[cfg(feature = "bigint")]
pub mod bigint;

2 changes: 1 addition & 1 deletion Sources/CTesseractShared/dummy.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Empty file simply to provide empty static module with headers
#include "tesseract-swift-utils.h"
#include "tesseract-swift-transports.h"
#include "tesseract-swift-transport.h"

0 comments on commit 86214b8

Please sign in to comment.