pub struct Topic(/* private fields */);Implementations§
Source§impl Topic
impl Topic
pub fn new(topic: [u8; 32]) -> Self
Sourcepub fn from_passphrase(phrase: &str) -> Self
pub fn from_passphrase(phrase: &str) -> Self
Examples found in repository?
examples/client.rs (line 10)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
async fn main() -> Result<()> {
let topic = Topic::from_passphrase("my test topic");
let _topic_id: TopicId = topic.clone().into();
let secret_key = SecretKey::generate(rand::rngs::OsRng);
let endpoint = Endpoint::builder()
.secret_key(secret_key)
.discovery_n0()
.discovery_dht()
.bind()
.await?;
let topic_tracker = Arc::new(TopicTracker::new(&endpoint));
let _router = iroh::protocol::Router::builder(endpoint.clone())
.accept(TopicTracker::ALPN, topic_tracker.clone())
.spawn()
.await?;
// Send a request
let node_ids_for_topic = topic_tracker.get_topic_nodes(&topic).await?;
println!("Iroh node_ids for topic: {:?}",node_ids_for_topic);
Ok(())
}pub fn to_string(&self) -> String
pub fn to_secret_key(&self) -> SecretKey
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Topic
impl<'de> Deserialize<'de> for Topic
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Topic
impl StructuralPartialEq for Topic
Auto Trait Implementations§
impl Freeze for Topic
impl RefUnwindSafe for Topic
impl Send for Topic
impl Sync for Topic
impl Unpin for Topic
impl UnwindSafe for Topic
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.