3I4PAA2AW3VUTA3HLS2G4TQMWB7BO25DMCC7VWJHG6WMHCBHR6JAC
NUAOEIXMKZO5KQWQ3TLQWO3RIXBPJU4QOPW7MGCV3ITDAUHFEK5QC
EEFI7RAXQQ4IMVWLW5PPNKKLO5WQQZPLXJKARNICTXZIM3XYJOFQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
6YMDOZIB5LVYLFIDGN2WNT5JTHEAMS4TFPVDEZ3OWXWOKJOC5QDAC
GHO6DWPILBBTL6CVZKERJBTFL3EY6ZT4YM4E5R4S6YPGVFKFHCVAC
VO5OQW4W2656DIYYRNZ3PO7TQ4JOKQ3GVWE5ALUTYVMX3WMXJOYQC
CCLLB7OIFNFYJZTG3UCI7536TOCWSCSXR67VELSB466R24WLJSDAC
I52XSRUH5RVHQBFWVMAQPTUSPAJ4KNVID2RMI3UGCVKFLYUO6WZAC
QMTANHVNRPQ5IX66FYQBFRBDCTN6YKMNCO6OHTQ6QCUASPWWXJKAC
YGPEHOTED5UG3IUK263PIX566VEHM3KYHPYIXZHPJ4ICHXWZEUJAC
TKEVOH7HXON7SOBGXTUDHAHO2U2GPTQRNESP6ERKUQAS526OZIRAC
IIV3EL2XYI2X7HZWKXEXQFAE3R3KC2Q7SGOT3Q332HSENMYVF32QC
I24UEJQLCH2SOXA4UHIYWTRDCHSOPU7AFTRUOTX7HZIAV4AZKYEQC
}
}
pub mod position_base32_serde {
use super::*;
use serde::*;
pub struct PositionDe {}
impl<'de> serde::de::Visitor<'de> for PositionDe {
type Value = Position<ChangeId>;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(formatter, "a base32-encoded string")
}
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
if let Some(b) = Position::from_base32(s.as_bytes()) {
Ok(b)
} else {
Err(de::Error::invalid_value(
serde::de::Unexpected::Str(s),
&self,
))
}
}
}
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Position<ChangeId>, D::Error> {
d.deserialize_str(PositionDe {})
pub fn internal_vertex<T: GraphTxnT>(
txn: &T,
v: &Vertex<Option<Hash>>,
change_id: ChangeId,
) -> Result<Vertex<ChangeId>, InconsistentChange<T::GraphError>> {
let change = if let Some(p) = v.change {
if let Some(&p) = txn.get_internal(&p.into())? {
p
} else {
return Err(InconsistentChange::UndeclaredDep);
}
} else {
change_id
};
Ok(Vertex {
change,
start: v.start,
end: v.end,
})
}
impl Base32 for Inode {
fn to_base32(&self) -> String {
let inode: u64 = self.0.into();
let mut b = [0; 8];
BigEndian::write_u64(&mut b, inode);
let mut bb = [0; 13];
data_encoding::BASE32_NOPAD.encode_mut(&b, &mut bb);
let b = std::str::from_utf8(&bb).unwrap();
b.to_string()
}
fn from_base32(s: &[u8]) -> Option<Self> {
let mut b = [0; 8];
if data_encoding::BASE32_NOPAD
.decode_mut(s, &mut b)
.is_ok()
{
Some(Inode(BigEndian::read_u64(&b).into()))
} else {
None
}
}
}
pub mod changeid_base32_serde {
use super::*;
use serde::*;
pub struct ChangeIdDe {}
impl<'de> serde::de::Visitor<'de> for ChangeIdDe {
type Value = ChangeId;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(formatter, "a base32-encoded string")
}
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
let mut b = [0; 8];
if data_encoding::BASE32_NOPAD
.decode_mut(s.as_bytes(), &mut b)
.is_ok()
{
let b: u64 = LittleEndian::read_u64(&b);
Ok(ChangeId(b.into()))
} else {
Err(de::Error::invalid_value(
serde::de::Unexpected::Str(s),
&self,
))
}
}
}
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<ChangeId, D::Error> {
d.deserialize_str(ChangeIdDe {})
}
pub fn serialize<S: Serializer>(inode: &ChangeId, s: S) -> Result<S::Ok, S::Error> {
let inode: u64 = inode.0.into();
let mut b = [0; 8];
LittleEndian::write_u64(&mut b, inode);
let mut bb = [0; 13];
data_encoding::BASE32_NOPAD.encode_mut(&b, &mut bb);
let b = std::str::from_utf8(&bb).unwrap();
s.serialize_str(b)
}
}
fn iter_graph_children<'txn, 'changes, P>(
&'txn self,
changes: &'changes P,
channel: &'txn Self::Channel,
key: pristine::Position<ChangeId>,
) -> Result<fs::GraphChildren<'txn, 'changes, Self, P>, Self::GraphError>
where
P: changestore::ChangeStore
{
fs::iter_graph_children(self, changes, &self.graph(channel), key)
}