Skip to content

Commit

Permalink
tune api
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Nov 19, 2024
1 parent eb7aee2 commit 1e811ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cidre/src/mc/browser_view_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl BrowserViewController {
pub fn with_service_type<'ear>(
service_type: &ns::String,
session: &mc::Session,
) -> Result<arc::R<Self>, &'ear ns::Exception> {
) -> ns::ExResult<'ear, arc::R<Self>> {
ns::try_catch(|| unsafe {
Self::alloc().init_with_service_type_throws(service_type, session)
})
Expand All @@ -54,7 +54,7 @@ impl BrowserViewController {
pub fn with_browser<'ear>(
browser: &mc::NearbyServiceBrowser,
session: &mc::Session,
) -> Result<arc::R<Self>, &'ear ns::Exception> {
) -> ns::ExResult<'ear, arc::R<Self>> {
ns::try_catch(|| unsafe { Self::alloc().init_with_browser_throws(browser, session) })
}

Expand Down
16 changes: 8 additions & 8 deletions cidre/src/mc/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl arc::A<Session> {
pub unsafe fn init_with_encryption_throws(
self,
peer: &mc::PeerId,
sec_identity: Option<ns::Array<ns::Id>>,
sec_identity: Option<&ns::Array<ns::Id>>,
encryption_preference: mc::EncryptionPreference,
) -> arc::R<Session>;
}
Expand All @@ -85,16 +85,16 @@ impl Session {

/// Create a session with an MCPeerID for the local peer.
#[inline]
pub fn with_peer<'ear>(peer: &mc::PeerId) -> Result<arc::R<Self>, &'ear ns::Exception> {
pub fn with_peer<'ear>(peer: &mc::PeerId) -> ns::ExResult<'ear, arc::R<Self>> {
ns::try_catch(|| unsafe { Self::alloc().init_with_peer_throws(peer) })
}

#[inline]
pub fn with_encryption<'ear>(
peer: &mc::PeerId,
sec_identity: Option<ns::Array<ns::Id>>,
sec_identity: Option<&ns::Array<ns::Id>>,
encryption_preference: mc::EncryptionPreference,
) -> Result<arc::R<Self>, &'ear ns::Exception> {
) -> ns::ExResult<'ear, arc::R<Self>> {
ns::try_catch(|| unsafe {
Self::alloc().init_with_encryption_throws(peer, sec_identity, encryption_preference)
})
Expand Down Expand Up @@ -155,21 +155,21 @@ impl Session {
&mut self,
stream_name: &ns::String,
to_peer: &mc::PeerId,
) -> Result<arc::R<ns::OutputStream>, &'ear ns::Error> {
) -> ns::Result<'ear, arc::R<ns::OutputStream>> {
ns::if_none(|err| unsafe { self.start_stream_err(stream_name, to_peer, err) })
}

#[objc::msg_send(myPeerID)]
pub fn my_peer_id(&self) -> &mc::PeerId;

#[objc::msg_send(securityIdentity)]
pub fn security_identity(&self) -> Option<&ns::Array<ns::Id>>;
pub fn security_identity(&self) -> Option<arc::R<ns::Array<ns::Id>>>;

#[objc::msg_send(encryptionPreference)]
pub fn encryption_preference(&self) -> mc::EncryptionPreference;

#[objc::msg_send(connectedPeers)]
pub fn connected_peers(&self) -> &ns::Array<mc::PeerId>;
pub fn connected_peers(&self) -> arc::R<ns::Array<mc::PeerId>>;
}

#[objc::protocol(MCSessionDelegate)]
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Session {
pub fn nearby_data_for_peer_ch_block(
&self,
peer: &mc::PeerId,
handler: &blocks::ResultCompletionHandler<ns::Data>,
handler: &mut blocks::ResultCompletionHandler<ns::Data>,
);

pub fn nearby_data_for_peer_ch(
Expand Down

0 comments on commit 1e811ee

Please sign in to comment.