Skip to content

Commit

Permalink
chore: remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Jan 24, 2024
1 parent 9a21ef9 commit fdbe680
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions crates/torii/client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use dojo_types::packing::unpack;
use dojo_types::schema::Ty;
use dojo_types::WorldMetadata;
use dojo_world::contracts::WorldContractReader;
use futures::channel::mpsc::{SendError, UnboundedSender};
use futures::channel::mpsc::{SendError, TrySendError, UnboundedSender};
use futures_util::{SinkExt, TryFutureExt};
use parking_lot::{RwLock, RwLockReadGuard};
use starknet::core::utils::cairo_short_string_to_felt;
Expand Down Expand Up @@ -102,40 +102,39 @@ impl Client {
})
}

/// Returns all of the subscribed topics of the libp2p client.
// pub fn subscribed_topics(&self) -> HashSet<String> {
// self.libp2p_client.topics.keys().cloned().collect()
// }

/// Subscribes to a topic.
/// Returns true if the topic was subscribed to.
/// Returns false if the topic was already subscribed to.
pub async fn subscribe_topic(&mut self, topic: &str) -> Result<(), SendError> {
pub fn subscribe_topic(
&mut self,
topic: &str,
) -> Result<(), TrySendError<torii_relay::client::Command>> {
self.libp2p_client
.command_sender
.send(torii_relay::client::Command::Subscribe(topic.to_string()))
.await
.unbounded_send(torii_relay::client::Command::Subscribe(topic.to_string()))
}

Check warning on line 115 in crates/torii/client/src/client/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/client/src/client/mod.rs#L108-L115

Added lines #L108 - L115 were not covered by tests

/// Unsubscribes from a topic.
/// Returns true if the topic was subscribed to.
pub async fn unsubscribe_topic(&mut self, topic: &str) -> Result<(), SendError> {
pub fn unsubscribe_topic(
&mut self,
topic: &str,
) -> Result<(), TrySendError<torii_relay::client::Command>> {
self.libp2p_client
.command_sender
.send(torii_relay::client::Command::Unsubscribe(topic.to_string()))
.await
.unbounded_send(torii_relay::client::Command::Unsubscribe(topic.to_string()))
}

Check warning on line 126 in crates/torii/client/src/client/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/client/src/client/mod.rs#L119-L126

Added lines #L119 - L126 were not covered by tests

/// Publishes a message to a topic.
/// Returns the message id.
pub async fn publish_message(&mut self, topic: &str, message: &[u8]) -> Result<(), SendError> {
self.libp2p_client
.command_sender
.send(torii_relay::client::Command::Publish(ClientMessage {
topic: topic.to_string(),
data: message.to_vec(),
}))
.await
pub fn publish_message(
&mut self,
topic: &str,
message: &[u8],
) -> Result<(), TrySendError<torii_relay::client::Command>> {
self.libp2p_client.command_sender.unbounded_send(torii_relay::client::Command::Publish(
ClientMessage { topic: topic.to_string(), data: message.to_vec() },
))
}

Check warning on line 138 in crates/torii/client/src/client/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/client/src/client/mod.rs#L130-L138

Added lines #L130 - L138 were not covered by tests

/// Runs the libp2p event loop which processes incoming messages and commands.
Expand Down

0 comments on commit fdbe680

Please sign in to comment.