libblobd_lite/op/
inspect_object.rs

1use super::OpError;
2use super::OpResult;
3use crate::bucket::FoundObject;
4use crate::ctx::Ctx;
5use std::sync::Arc;
6use tinybuf::TinyBuf;
7
8pub struct OpInspectObjectInput {
9  pub key: TinyBuf,
10  // Only useful if versioning is enabled.
11  pub id: Option<u64>,
12}
13
14pub struct OpInspectObjectOutput {
15  pub id: u64,
16  pub size: u64,
17}
18
19pub(crate) async fn op_inspect_object(
20  ctx: Arc<Ctx>,
21  req: OpInspectObjectInput,
22) -> OpResult<OpInspectObjectOutput> {
23  let bkt = ctx.buckets.get_bucket_for_key(&req.key).await;
24  let Some(FoundObject { id, size, .. }) = bkt.find_object(req.id).await else {
25    return Err(OpError::ObjectNotFound);
26  };
27
28  Ok(OpInspectObjectOutput { id, size })
29}