Read the current lease record, if any.
(&self)
| 216 | |
| 217 | /// Read the current lease record, if any. |
| 218 | pub async fn read(&self) -> Result<Option<LeaseRecord>, LeaseError> { |
| 219 | let record = self |
| 220 | .store |
| 221 | .get(LEASE_OBJECT_TYPE, LEASE_SINGLETON_ID) |
| 222 | .await |
| 223 | .map_err(LeaseError::Store)?; |
| 224 | let Some(record) = record else { |
| 225 | return Ok(None); |
| 226 | }; |
| 227 | |
| 228 | let payload: LeasePayload = serde_json::from_slice(&record.payload) |
| 229 | .map_err(|e| PersistenceError::Decode(e.to_string()))?; |
| 230 | |
| 231 | Ok(Some(LeaseRecord { |
| 232 | holder: payload.holder, |
| 233 | acquired_at_ms: payload.acquired_at_ms, |
| 234 | resource_version: record.resource_version, |
| 235 | updated_at_ms: record.updated_at_ms, |
| 236 | })) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /// Derive a stable replica identity for lease ownership. |