12345678module remote9101112pub struct Object {13pub:14 found bool15 body []u816 tag string17}1819202122pub interface Backend {23mut:24 get(key string) !Object25 list(prefix string) ![]string26 put_if_absent(key string, body []u8) !bool27 put_if_match(key string, body []u8, tag string) !bool28 delete(key string) !29}3031pub const probe_key = 'koh-probe'3233343536pub fn check(mut backend Backend) ! {37 payload := 'koh probe'.bytes()38 if !backend.put_if_absent(probe_key, payload)! {39 return error('the remote already has a probe object — it is not empty, or it cannot refuse a second write')40 }41 if backend.put_if_absent(probe_key, payload)! {42 backend.delete(probe_key)!43 return error('the remote overwrote an existing object — conditional writes are not working')44 }45 probe := backend.get(probe_key)!46 if !probe.found || probe.body != payload {47 return error('the remote did not give back what was written')48 }49 backend.delete(probe_key)!50}