Skip to content

Commit cd6f617

Browse files
committed
Take &mut self consistently
In order to implement proper error handling, we are going to need to also access the singleton child process state. (In the future we should support concurrent blob fetches which would return the `std::fs::File` which can be accessed concurrently/separately from the proxy. But our users aren't doing concurrent fetches yet)
1 parent 2d5ef6c commit cd6f617

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/imageproxy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl ImageProxy {
217217
}
218218

219219
async fn impl_request<R: serde::de::DeserializeOwned + Send + 'static, T, I>(
220-
&self,
220+
&mut self,
221221
method: &str,
222222
args: T,
223223
) -> Result<(R, Option<(File, u32)>)>
@@ -229,29 +229,29 @@ impl ImageProxy {
229229
Self::impl_request_raw(Arc::clone(&self.sockfd), req).await
230230
}
231231

232-
async fn finish_pipe(&self, pipeid: u32) -> Result<()> {
232+
async fn finish_pipe(&mut self, pipeid: u32) -> Result<()> {
233233
let (r, fd) = self.impl_request("FinishPipe", [pipeid]).await?;
234234
if fd.is_some() {
235235
return Err(anyhow!("Unexpected fd in finish_pipe reply"));
236236
}
237237
Ok(r)
238238
}
239239

240-
pub async fn open_image(&self, imgref: &str) -> Result<OpenedImage> {
240+
pub async fn open_image(&mut self, imgref: &str) -> Result<OpenedImage> {
241241
let (imgid, _) = self
242242
.impl_request::<u32, _, _>("OpenImage", [imgref])
243243
.await?;
244244
Ok(OpenedImage(imgid))
245245
}
246246

247-
pub async fn close_image(&self, img: &OpenedImage) -> Result<()> {
247+
pub async fn close_image(&mut self, img: &OpenedImage) -> Result<()> {
248248
let (r, _) = self.impl_request("CloseImage", [img.0]).await?;
249249
Ok(r)
250250
}
251251

252252
/// Fetch the manifest.
253253
/// https://github.com/opencontainers/image-spec/blob/main/manifest.md
254-
pub async fn fetch_manifest(&self, img: &OpenedImage) -> Result<(String, Vec<u8>)> {
254+
pub async fn fetch_manifest(&mut self, img: &OpenedImage) -> Result<(String, Vec<u8>)> {
255255
let (digest, fd) = self.impl_request("GetManifest", [img.0]).await?;
256256
let (fd, pipeid) = fd.ok_or_else(|| anyhow!("Missing fd from reply"))?;
257257
let mut fd = tokio::io::BufReader::new(tokio::fs::File::from_std(fd));
@@ -268,7 +268,7 @@ impl ImageProxy {
268268
/// Note that right now the proxy does verification of the digest:
269269
/// https://github.com/cgwalters/container-image-proxy/issues/1#issuecomment-926712009
270270
pub async fn get_blob(
271-
&self,
271+
&mut self,
272272
img: &OpenedImage,
273273
digest: &str,
274274
size: u64,

0 commit comments

Comments
 (0)