mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-08 17:47:18 +00:00
Kernel: Add NetworkingManagement::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly propagate errors.
This commit is contained in:
committed by
Andreas Kling
parent
da5d678f2a
commit
74ab8ccde0
@@ -50,6 +50,15 @@ void NetworkingManagement::for_each(Function<void(NetworkAdapter&)> callback)
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<void> NetworkingManagement::try_for_each(Function<ErrorOr<void>(NetworkAdapter&)> callback)
|
||||
{
|
||||
return m_adapters.with([&](auto& adapters) -> ErrorOr<void> {
|
||||
for (auto& adapter : adapters)
|
||||
TRY(callback(adapter));
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<NetworkAdapter> NetworkingManagement::from_ipv4_address(IPv4Address const& address) const
|
||||
{
|
||||
if (address[0] == 0 && address[1] == 0 && address[2] == 0 && address[3] == 0)
|
||||
|
||||
Reference in New Issue
Block a user