pub struct TopicTracker {
pub node_id: NodeId,
/* private fields */
}Fields§
§node_id: NodeIdImplementations§
Source§impl TopicTracker
impl TopicTracker
pub const ALPN: &'static [u8] = b"iroh/topictracker/1"
pub const MAX_TOPIC_LIST_SIZE: usize = 10usize
pub const MAX_NODE_IDS_PER_TOPIC: usize = 100usize
pub const BOOTSTRAP_NODES: &str = "abcdef4df4d74587095d071406c2a8462bde5079cbbc0c50051b9b2e84d67691"
Sourcepub fn new(endpoint: &Endpoint) -> Self
pub fn new(endpoint: &Endpoint) -> Self
Examples found in repository?
examples/server.rs (line 20)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
async fn main() -> Result<()> {
let secret_key = SecretKey::from_str(SECRET_SERVER_KEY)?;
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?;
let from = tokio::io::stdin();
let mut lines = BufReader::new(from).lines();
while let Some(_) = lines.next_line().await? {
println!("{:?}",topic_tracker.memory_footprint().await);
}
Ok(())
}More examples
examples/client.rs (line 21)
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(())
}Sourcepub async fn get_topic_nodes(
self: Arc<Self>,
topic: &Topic,
) -> Result<Vec<NodeId>>
pub async fn get_topic_nodes( self: Arc<Self>, topic: &Topic, ) -> Result<Vec<NodeId>>
Examples found in repository?
examples/client.rs (line 28)
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(())
}Sourcepub async fn memory_footprint(&self) -> usize
pub async fn memory_footprint(&self) -> usize
Examples found in repository?
examples/server.rs (line 29)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
async fn main() -> Result<()> {
let secret_key = SecretKey::from_str(SECRET_SERVER_KEY)?;
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?;
let from = tokio::io::stdin();
let mut lines = BufReader::new(from).lines();
while let Some(_) = lines.next_line().await? {
println!("{:?}",topic_tracker.memory_footprint().await);
}
Ok(())
}Trait Implementations§
Source§impl Clone for TopicTracker
impl Clone for TopicTracker
Source§fn clone(&self) -> TopicTracker
fn clone(&self) -> TopicTracker
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TopicTracker
impl Debug for TopicTracker
Auto Trait Implementations§
impl Freeze for TopicTracker
impl !RefUnwindSafe for TopicTracker
impl Send for TopicTracker
impl Sync for TopicTracker
impl Unpin for TopicTracker
impl !UnwindSafe for TopicTracker
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