Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrowsingContext: An asynchronous, pollable service discovery struct #3

Open
nukkeldev opened this issue Feb 24, 2024 · 1 comment
Open

Comments

@nukkeldev
Copy link
Owner

BrowsingContext allows for the user to declare a single, or multiple, type(s) of services they are interested in and poll the instance to get discovered Services.

Usage of this might look something like:

let ctx: BrowsingContext = BrowsingContext::new().query("_http._tcp.local").query("_http-alt._tcp.local").search();
let mut services = vec![];

loop {
    if let Some(service) = ctx.poll() {
        services.push(service);
    }

    // ...
}

I take inspiration to other APIs that do similar things, such as sockets, IO, etc., and have a sort of queue-based polling system which I think works well for now. If not, I can change it at a later date, but it will suffice for an initial implementation.

@nukkeldev
Copy link
Owner Author

Actually, on second thought, polling would be unfit for the sorts of applications I want to use this for, those being non-immediate mode UI. Rather an Arc<Mutex<Vec<Service>>> might be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant