Skip to content

Commit 5e2deb5

Browse files
imageproxy: make .impl_request() generic over fds
...and the presence of a pipe ID. Create a new internal PipeId structure to keep track of pipe ids on the server. This is a very small wrapper around NonZeroU32. Have .impl_request() return a Result<> of a 3-tuple: - a deserialized result, as before - a fixed-sized array of fds ([OwnedFd; N]) - a fixed-sized array of PipeIds ([PipeId; M]) Introduce a bit of generics magic to make sure that we got the expected number of fds and pipeids from the other side, or an error. Then you can make calls like: - `let ((), [], []) = self.impl_request("CloseImage", [img.0]).await?;` - `let (digest, [datafd], [pipeid]) = self.impl_request("GetManifest", [img.0]).await?;` - `let (bloblen, [datafd, errfd], []) = self.impl_request("GetRawBlob", args).await?;` and you'll get an Ok() with the statically-correct number of fds and pipeids, or you'll get an Err() with a message why, like: Expected 1 OwnedFd but got 0 Of course, we can only ever have 0 or 1 PipeIds, but the fixed-sized array syntax has rather nice ergonomics here and its lets us share logic with the fds. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 48682ab commit 5e2deb5

File tree

1 file changed

+117
-164
lines changed

1 file changed

+117
-164
lines changed

0 commit comments

Comments
 (0)