Repository navigation
feat: add instance_name_unescaped() to get a readable instance name - #552
Merged
Merged
Conversation
Since #540, a fullname read from the network keeps its RFC 6763 escapes, e.g. "L\.A\.R\.A Hub._lara._tcp.local.". Add a public instance_name_unescaped() that returns the first label of a fullname unescaped ("L.A.R.A Hub"). Co-Authored-By: Claude Opus 5.5 <[email protected]>
keepsimple1
force-pushed
the
instance-name-helper
branch
from
November 16, 2026 06:25
4414e0b to
6c2b4ec
Compare
Note on ResolvedService.fullname, ResolvedService::get_fullname(), ServiceEvent::ServiceFound and ServiceEvent::ServiceRemoved that the fullname escapes dots and backslashes in the instance name, and link to instance_name_unescaped(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
keepsimple1
added a commit
that referenced
this pull request
Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #540, before the 0.22.0 release (#551).
Problem
Since #540, a fullname read from the network keeps its RFC 6763 section 4.3 escapes, so it equals the registered fullname. For an instance named
L.A.R.A Hub,ServiceFound,ServiceRemovedandResolvedService.fullnamenow giveL\.A\.R\.A Hub._lara._tcp.local.. To show the readable name, a user has to split the fullname on unescaped dots and remove the escapes themselves.Change
Add one public function,
mdns_sd::instance_name_unescaped(fullname: &str) -> String. It returns the first label offullnamewith\.and\\unescaped, i.e. the name given toServiceInfo::new():String. It doesn't validatefullname: it returns the part before the first unescaped dot, unescaped, or the whole string unescaped if there is no unescaped dot ("no-dot"gives"no-dot",""gives""). The fullnames it is meant for come from the daemon's own events, so callers shouldn't have to handle aNonethat never happens.ResolvedService.fullname,ResolvedService::get_fullname(),ServiceEvent::ServiceFoundandServiceEvent::ServiceRemovednow say the fullname is escaped and link to the new function.This is deliberately minimal. Getters on
ResolvedService/ServiceInfoor a whole-name unescape can be added later once we know what users need.Tests
test_instance_name_unescaped: plain names, escaped dots and backslashes,\\right before the separator dot, a stray backslash, UTF-8, and inputs that aren't fullnames.test_instance_name_unescaped_round_trip:ServiceInfo::new(name)and theninstance_name_unescaped(get_fullname())gives backname.test_rfc6763_utf8_network_integrationnow also checks that the resolved fullname gives back the registered instance name.AI assistance: Claude Code