Coder Social home page Coder Social logo

Comments (9)

dalepsmith avatar dalepsmith commented on August 16, 2024

Having TXT records be HashMap<String, String> is a very nice and logical API.

However, Keys are not utf-8, only printable ascii.
And the Values can be any sequence of bytes (including '='), again not utf-8.

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

Thanks for the details!

New publish does not have TXT
If start browsing, existing services have TXT record info.
If I publish a service (with avahi-publish-service), the TXT info is missing.
But if I publish BEFORE I start the browse, I do get the TXT info.

This is a bug and worth a separate issue. Would you mind open another issue for it?

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

However, Keys are not utf-8, only printable ascii.

UTF-8 is backward compatible with ascii. So it's fine to represent ascii using utf-8.

And the Values can be any sequence of bytes (including '='), again not utf-8.

I didn't know that, thanks for pointing it out. Before we change, do you have use cases where you do need to support non-UTF-8 values? I'm trying to see benefit/cost ratio.

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

For other key/value rules, I agree we should fix the code using this issue.

from mdns-sd.

dalepsmith avatar dalepsmith commented on August 16, 2024

from mdns-sd.

dalepsmith avatar dalepsmith commented on August 16, 2024

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

As far as receiving, yes this is fine. However, publishing should verify that the key has only the allowed characters (0x20 - 0x7e, except for '=').

Good point. I think we can check it in ServiceInfo::new().

I don't know of any specifically. Just noticed it while reading the RFC. I would imagine most values are just text, But since the spec allows it, it's probably out there, or will be. Best be prepared to handle it somehow.

Maybe I'm biased, but I think the world is moving towards UTF-8. It is possible that some rare applications use non-UTF-8 in TXT records but I'm willing to postpone this until a concrete case shows up in our context.

(Some other types in Rust ecosystem face / faced the same problem, for example std::path::Path. IMO, the history shows that supporting non-UTF-8 things in a mostly UTF-8 environment can be costly for the end users.)

Also, the no-key and empty key cases ("key" and "key=") should be distinguished somehow. Maybe with an Option<> ?

Yes, that sounds good to me. And maybe we can take this opportunity to define a type X for TXT key/value pairs so that ServiceInfo::new() accepts X or Option<X> instead of the plain HashMap<String, String>. Also, maybe we keep the new() as is (deprecate it later), and add a new / better constructor for ServiceInfo, maybe even using Builder pattern or something?

And with a new type for TXT k/v pairs and a new constructor, it might be easier to be flexible in supporting non-UTF-8 values (now or later).

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

Two of the problems are resolved in their separated issues:

  • Last Key: #76 .
  • New publish does not have TXT: #72 .

from mdns-sd.

keepsimple1 avatar keepsimple1 commented on August 16, 2024

All issues mentioned above are addressed in Release 0.7.0. If any problems, please open a new issue.

Thanks again @dalepsmith for opening this issue and helping solving them. If anything not working properly, please raise them.

from mdns-sd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.