1- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
21use anyhow:: Result ;
3- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
42use bytes:: Bytes ;
5- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
63use iroh:: { Endpoint , protocol:: Router } ;
7- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
84use iroh_blobs:: { net_protocol:: Blobs , ticket:: BlobTicket } ;
9- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
105use std:: error:: Error ;
116use std:: ffi:: CString ;
127
13- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
148use crate :: lean:: ffi:: raw_to_str;
159use crate :: lean:: {
1610 ffi:: { CResult , c_char, to_raw} ,
1711 sarray:: LeanSArrayObject ,
1812} ;
1913
20- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
2114#[ unsafe( no_mangle) ]
2215extern "C" fn rs_iroh_send ( bytes : & LeanSArrayObject ) -> * const CResult {
2316 // Create a Tokio runtime to block on the async function
@@ -41,19 +34,6 @@ extern "C" fn rs_iroh_send(bytes: &LeanSArrayObject) -> *const CResult {
4134 to_raw ( c_result)
4235}
4336
44- #[ cfg( all( target_os = "macos" , target_arch = "aarch64" ) ) ]
45- #[ unsafe( no_mangle) ]
46- extern "C" fn rs_iroh_send ( _bytes : & LeanSArrayObject ) -> * const CResult {
47- let msg = CString :: new ( "Iroh functions not supported on MacOS aarch64-darwin" )
48- . expect ( "CString::new failure" ) ;
49- let c_result = CResult {
50- is_ok : false ,
51- data : msg. into_raw ( ) . cast ( ) ,
52- } ;
53- to_raw ( c_result)
54- }
55-
56- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
5737async fn iroh_send ( bytes : & [ u8 ] ) -> Result < ( ) , Box < dyn Error > > {
5838 // Create an endpoint, it allows creating and accepting
5939 // connections in the iroh p2p world
@@ -91,7 +71,6 @@ async fn iroh_send(bytes: &[u8]) -> Result<(), Box<dyn Error>> {
9171 Ok ( ( ) )
9272}
9373
94- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
9574#[ unsafe( no_mangle) ]
9675extern "C" fn rs_iroh_recv (
9776 ticket : * const c_char ,
@@ -125,23 +104,6 @@ extern "C" fn rs_iroh_recv(
125104 to_raw ( c_result)
126105}
127106
128- #[ cfg( all( target_os = "macos" , target_arch = "aarch64" ) ) ]
129- #[ unsafe( no_mangle) ]
130- extern "C" fn rs_iroh_recv (
131- _ticket : * const c_char ,
132- _buffer : & mut LeanSArrayObject ,
133- _buffer_capacity : usize ,
134- ) -> * const CResult {
135- let msg = CString :: new ( "Iroh functions not supported on MacOS aarch64-darwin" )
136- . expect ( "CString::new failure" ) ;
137- let c_result = CResult {
138- is_ok : false ,
139- data : msg. into_raw ( ) . cast ( ) ,
140- } ;
141- to_raw ( c_result)
142- }
143-
144- #[ cfg( not( all( target_os = "macos" , target_arch = "aarch64" ) ) ) ]
145107async fn iroh_recv ( ticket : & str , buffer_capacity : usize ) -> Result < Bytes , Box < dyn Error > > {
146108 // Create an endpoint, it allows creating and accepting
147109 // connections in the iroh p2p world
0 commit comments