refactor: remove AsMut<Pubsub> in favor of getter
neither looks too good but AsMut<Pubsub> trick cannot be played with multiple components so there goes that idea.
This commit is contained in:
parent
a068e2565b
commit
cd26d39857
12
src/lib.rs
12
src/lib.rs
@ -615,24 +615,24 @@ impl<Types: SwarmTypes> Future for IpfsFuture<Types> {
|
||||
let _ = ret.send(addresses);
|
||||
}
|
||||
IpfsEvent::PubsubSubscribe(topic, ret) => {
|
||||
let _ = ret.send(self.swarm.as_mut().subscribe(topic));
|
||||
let _ = ret.send(self.swarm.pubsub().subscribe(topic));
|
||||
}
|
||||
IpfsEvent::PubsubUnsubscribe(topic, ret) => {
|
||||
let _ = ret.send(self.swarm.as_mut().unsubscribe(topic));
|
||||
let _ = ret.send(self.swarm.pubsub().unsubscribe(topic));
|
||||
}
|
||||
IpfsEvent::PubsubPublish(topic, data, ret) => {
|
||||
self.swarm.as_mut().publish(topic, data);
|
||||
self.swarm.pubsub().publish(topic, data);
|
||||
let _ = ret.send(());
|
||||
}
|
||||
IpfsEvent::PubsubPeers(Some(topic), ret) => {
|
||||
let topic = libp2p::floodsub::Topic::new(topic);
|
||||
let _ = ret.send(self.swarm.as_mut().subscribed_peers(&topic));
|
||||
let _ = ret.send(self.swarm.pubsub().subscribed_peers(&topic));
|
||||
}
|
||||
IpfsEvent::PubsubPeers(None, ret) => {
|
||||
let _ = ret.send(self.swarm.as_mut().known_peers());
|
||||
let _ = ret.send(self.swarm.pubsub().known_peers());
|
||||
}
|
||||
IpfsEvent::PubsubSubscribed(ret) => {
|
||||
let _ = ret.send(self.swarm.as_mut().subscribed_topics());
|
||||
let _ = ret.send(self.swarm.pubsub().subscribed_topics());
|
||||
}
|
||||
IpfsEvent::WantList(peer, ret) => {
|
||||
todo!()
|
||||
|
@ -232,10 +232,8 @@ impl<TSwarmTypes: SwarmTypes> Behaviour<TSwarmTypes> {
|
||||
//let hash = Multihash::from_bytes(cid.to_bytes()).unwrap();
|
||||
//self.kademlia.remove_providing(&hash);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SwarmTypes> std::convert::AsMut<Pubsub> for Behaviour<T> {
|
||||
fn as_mut(&mut self) -> &mut Pubsub {
|
||||
pub fn pubsub(&mut self) -> &mut Pubsub {
|
||||
&mut self.pubsub
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user