radicle-git-ext: remove multihash and minicbor

Multihash was deemed as not needed for compatibility since it is
possible to detect a change from SHA1 to SHA256 based on their encoded
lengths. The YAGNI principle is executed and multihash (and minicbor
while we're here) are removed.

This also had an effect on `Urn` which relied heavily on encoding the
value using multihash. The `urn` and `namespace` modules were removed
from radicle-git-types, since they were likely not going to be used
anyway.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-11-04 12:25:02 +00:00
parent bf33be9220
commit 0728ee1f66
9 changed files with 18 additions and 754 deletions
-74
View File
@@ -635,77 +635,3 @@ impl From<&git_ref_format::refspec::PatternStr> for RefspecPattern {
Self(r.to_owned().into())
}
}
#[cfg(feature = "minicbor")]
mod minicbor_impls {
use super::*;
use minicbor::{
decode,
encode::{self, Write},
Decode,
Decoder,
Encode,
Encoder,
};
impl Encode for RefLike {
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
e.str(self.as_str())?;
Ok(())
}
}
impl<'b> Decode<'b> for RefLike {
fn decode(d: &mut Decoder) -> Result<Self, decode::Error> {
let path = d.str()?;
Self::try_from(path).or(Err(decode::Error::Message("invalid reflike")))
}
}
impl minicbor::Encode for OneLevel {
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
e.str(self.as_str())?;
Ok(())
}
}
impl<'b> Decode<'b> for OneLevel {
fn decode(d: &mut Decoder) -> Result<Self, decode::Error> {
let refl: RefLike = Decode::decode(d)?;
Ok(Self::from(refl))
}
}
impl Encode for Qualified {
fn encode<W: encode::Write>(
&self,
e: &mut Encoder<W>,
) -> Result<(), encode::Error<W::Error>> {
e.str(self.as_str())?;
Ok(())
}
}
impl<'b> Decode<'b> for Qualified {
fn decode(d: &mut Decoder) -> Result<Self, decode::Error> {
let refl: RefLike = Decode::decode(d)?;
Ok(Self::from(refl))
}
}
impl Encode for RefspecPattern {
fn encode<W: encode::Write>(
&self,
e: &mut Encoder<W>,
) -> Result<(), encode::Error<W::Error>> {
e.str(self.as_str())?;
Ok(())
}
}
impl<'b> Decode<'b> for RefspecPattern {
fn decode(d: &mut Decoder) -> Result<Self, decode::Error> {
Self::try_from(d.str()?).or(Err(decode::Error::Message("invalid refspec pattern")))
}
}
}