Deliver an event enum with the queue overflow as its own case

The stream's element is now the enum InotifyEvent, and the struct that
describes a change to a watched item is FileSystemEvent. A queue
overflow was an event with descriptor -1 and an empty path that every
consumer had to know about; as a case, the compiler makes them handle
it. The enum is also where failed watches of a growing tree will be
reported, since no call site can catch them.
This commit is contained in:
T. R. Bernstein
2026-09-19 00:10:35 +02:00
parent f01e16e864
commit 3c852a565c
8 changed files with 94 additions and 52 deletions
@@ -50,7 +50,7 @@ struct InotifyLimitTests {
var received = 0
for await event in await watcher.events {
received += 1
if event.mask.contains(.queueOverflow) { return (event, received) }
if case .queueOverflow = event { return (event, received) }
}
return (nil, received)
}
@@ -65,9 +65,7 @@ struct InotifyLimitTests {
overflowTask.cancel()
let (overflow, received) = await overflowTask.value
#expect(overflow != nil, "Expected a queue overflow event after \(index) file creations and \(received) received events")
#expect(overflow?.watchDescriptor == -1)
#expect(overflow?.path == "")
#expect(overflow == .queueOverflow, "Expected a queue overflow event after \(index) file creations and \(received) received events")
}
}
}