/vault/set/{channel}

Kind 6: a key written; ok or an error, in exactly one message.

The ask is kind 6 on /requests:

[6][key_len: u16, big-endian][key …][value …]

The server answers on /vault/set/{channel} by sending exactly one message and closing the connection. A path that the proxy or the server closes cleanly with no message before the close states that the ask was not served. An abrupt end of the path leaves the operation failed, and the proxy does not ask it again, as Vault provides.

The ask is defined by diverge-provider-sdk/src/shared/containers/vault/set/request/request.rs:

//! Write a key.

use super::super::super::{RequestEncodeError, RequestError};
use crate::encode::{Encode, Writer};

/// Write a key, creating or replacing it. Answered `Ok`.
///
/// ```text
/// [key_len: u16 BE][key: utf8…][value…]
/// ```
///
/// The one operation whose key has a length prefix, because a value
/// follows it and nothing else delimits the two. Answered with one
/// [`response::Frame`](super::super::response::Frame).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Request<'a> {
    /// The key.
    pub key: &'a str,
    /// The value, verbatim. Empty is a value.
    pub value: &'a [u8],
}

/// The bytes the key's length occupies.
const KEY_LEN: usize = 2;

impl Encode for Request<'_> {
    /// One way to fail: a key longer than the length prefix holds.
    type Error = RequestEncodeError;

    fn encode(&self, out: &mut Writer<'_>) -> Result<(), RequestEncodeError> {
        let key = self.key.as_bytes();
        let len = u16::try_from(key.len())
            .map_err(|_| RequestEncodeError::KeyLength(key.len()))?;
        out.extend_from_slice(&len.to_be_bytes());
        out.extend_from_slice(key);
        out.extend_from_slice(self.value);
        Ok(())
    }
}

impl<'a> Request<'a> {
    /// Decode from the bytes after the ask's kind. The key and the
    /// value borrow from `bytes`.
    pub fn decode(bytes: &'a [u8]) -> Result<Self, RequestError> {
        let len: &[u8; KEY_LEN] = bytes
            .get(..KEY_LEN)
            .and_then(|head| head.try_into().ok())
            .ok_or(RequestError::Truncated)?;
        let len = usize::from(u16::from_be_bytes(*len));
        let rest = &bytes[KEY_LEN..];
        let key = rest.get(..len).ok_or(RequestError::Truncated)?;
        let key = std::str::from_utf8(key).map_err(|_| RequestError::KeyUtf8)?;
        Ok(Request {
            key,
            value: &rest[len..],
        })
    }
}

The answer is the frame defined on Vault: a first byte of 0 states that the operation was done; a first byte of 1 is followed by a message stating why it was not.