mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:45:06 +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:
parent
da5d678f2a
commit
74ab8ccde0
2 changed files with 10 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue