/// Writes mutations to the initial Registry
Writes mutations to the initial Registry
Writes mutations to the initial Registry
pub fn add_mutations(
        &self,
        mutations: Vec<RegistryMutation>,
    ) -> Result<(), ProtoRegistryDataProviderError> {
        let mut records = self.records.write().unwrap();
        let version = INITIAL_REGISTRY_VERSION;
        for mutation in mutations {
            let key = std::str::from_utf8(&mutation.key)
                .expect("Expected registry key to be utf8-encoded");
            let search_key = &(&version.get(), key);
            match records.binary_search_by_key(search_key, |r| (&r.version, &r.key)) {
                Ok(_) => {
                    return Err(ProtoRegistryDataProviderError::KeyAlreadyExists {
                        key: key.to_string(),
                        version,
                    })
                }
                Err(idx) => {
                    let record = ProtoRegistryRecord {
                        key: key.to_string(),
                        version: version.get(),
                        value: Some(mutation.value),
                    };
                    records.insert(idx, record);
                }
            }
        }
        Ok(())
    }
pub fn add_mutations ( & self , mutations : Vec < RegistryMutation > , ) -> Result < ( ) , ProtoRegistryDataProviderError > { let mut records = self . records . write ( ) . unwrap ( ) ; let version = INITIAL_REGISTRY_VERSION ; for mutation in mutations { let key = std :: str :: from_utf8 ( & mutation . key ) . expect ( " " ) ; let search_key = & ( & version . get ( ) , key ) ; match records . binary_search_by_key ( search_key , | r | ( & r . version , & r . key ) ) { Ok ( _ ) => { return Err ( ProtoRegistryDataProviderError :: KeyAlreadyExists { key : key . to_string ( ) , version , } ) } Err ( idx ) => { let record = ProtoRegistryRecord { key : key . to_string ( ) , version : version . get ( ) , value : Some ( mutation . value ) , } ; records . insert ( idx , record ) ; } } } Ok ( ( ) ) }
Writes mutations to the initial Registry
Writes mutations to the initial Registry
&self
mutations
Vec<RegistryMutation>