Skip to content

Commit 0df2b47

Browse files
allisonkarlitskayacgwalters
authored andcommitted
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]> Signed-off-by: Colin Walters <[email protected]>
1 parent 7f6718c commit 0df2b47

File tree

1 file changed

+110
-164
lines changed

1 file changed

+110
-164
lines changed

0 commit comments

Comments
 (0)