-
-
Notifications
You must be signed in to change notification settings - Fork 140
Rewrite ::address (import from dbus_addr) #989
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d5164c6
🚚 zb: move address to legacy_address
elmarco b5293c7
✨ zb: add new address module implementation
elmarco 803a7d5
✨ zb: add From<address::Error>
elmarco db090f5
💥 zb: change connection, handle ;-separated address
elmarco 175cb5b
♻️ zb: handle TCP transport connection (without legacy_address)
elmarco b31033d
♻️ zb: move TCP connection test
elmarco beb6d81
♻️ zb: handle NonceTCP transport (without legacy_address)
elmarco bb85a98
♻️ zb: move NonceTCP connection test
elmarco fbed501
♻️ zb: handle Unix transport (without legacy_address)
elmarco 1a93abd
♻️ zb: handle Vsock transport connection (without legacy_address)
elmarco 36020eb
♻️ zb: handle Launchd transport connection (without legacy_address)
elmarco c62289d
♻️ zb: move Launchd connection test
elmarco bcaad6e
♻️ zb: make windows_autolaunch_bus_address() return String
elmarco 4d2cdfd
✨ zb: make connect() recursively callable
elmarco a9dbca6
♻️ zb: handle win32 Autolaunch connection (without legacy_address)
elmarco 00b2c35
♻️ zb: move win32 Autolaunch connection test
elmarco c2c6d42
🔥 zb: drop legacy_address module
elmarco dec224c
➖ zb: drop async-recursion dependency
elmarco 979019c
🚚 zb: rename DBusAddr to Address
elmarco 2dc80c4
🩹 zb: make address parsing target-specific
elmarco 0b4362b
🚚 zb: src/connection/connect.rs ⟶ src/connection/connect/mod.rs
elmarco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| use std::{borrow::Cow, fmt}; | ||
|
|
||
| use super::{Address, Error, Result, ToAddresses}; | ||
|
|
||
| /// A bus address list. | ||
| /// | ||
| /// D-Bus addresses are `;`-separated. | ||
| #[derive(Debug, PartialEq, Eq, Clone)] | ||
| pub struct AddressList<'a> { | ||
| addr: Cow<'a, str>, | ||
| } | ||
|
|
||
| impl<'a> ToAddresses<'a> for AddressList<'a> { | ||
| type Iter = AddressListIter<'a>; | ||
|
|
||
| /// Get an iterator over the D-Bus addresses. | ||
| fn to_addresses(&'a self) -> Self::Iter { | ||
| AddressListIter::new(self) | ||
| } | ||
| } | ||
|
|
||
| impl<'a> Iterator for AddressListIter<'a> { | ||
| type Item = Result<Address<'a>>; | ||
|
|
||
| fn next(&mut self) -> Option<Self::Item> { | ||
| if self.next_index >= self.data.len() { | ||
| return None; | ||
| } | ||
|
|
||
| let mut addr = &self.data[self.next_index..]; | ||
| if let Some(end) = addr.find(';') { | ||
| addr = &addr[..end]; | ||
| self.next_index += end + 1; | ||
| } else { | ||
| self.next_index = self.data.len(); | ||
| } | ||
|
|
||
| Some(Address::try_from(addr)) | ||
| } | ||
| } | ||
|
|
||
| /// An iterator of D-Bus addresses. | ||
| pub struct AddressListIter<'a> { | ||
| data: &'a str, | ||
| next_index: usize, | ||
| } | ||
|
|
||
| impl<'a> AddressListIter<'a> { | ||
| fn new(list: &'a AddressList<'_>) -> Self { | ||
| Self { | ||
| data: list.addr.as_ref(), | ||
| next_index: 0, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<'a> TryFrom<String> for AddressList<'a> { | ||
| type Error = Error; | ||
|
|
||
| fn try_from(value: String) -> Result<Self> { | ||
| Ok(Self { | ||
| addr: Cow::Owned(value), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl<'a> TryFrom<&'a str> for AddressList<'a> { | ||
| type Error = Error; | ||
|
|
||
| fn try_from(value: &'a str) -> Result<Self> { | ||
| Ok(Self { | ||
| addr: Cow::Borrowed(value), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl fmt::Display for AddressList<'_> { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| write!(f, "{}", self.addr) | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.