Making a few types and methods public

pmeunier
Oct 19, 2021, 11:24 AM
3I4PAA2AW3VUTA3HLS2G4TQMWB7BO25DMCC7VWJHG6WMHCBHR6JAC

Dependencies

  • [2] NUAOEIXM Adding inode and byte to Local
  • [3] EEFI7RAX Alternative Inode serializer (as a Base32 str)
  • [4] 6YMDOZIB Refactoring apply
  • [5] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [6] TKEVOH7H Fixing a bug when downloading changes, and making change download more efficient (more async)
  • [7] YN63NUZO Sanakirja 1.0
  • [8] VO5OQW4W Removing anyhow in libpijul
  • [9] GHO6DWPI Refactoring iterators
  • [10] YGPEHOTE libpijul::fs::add_{file,dir} now return the created Inode
  • [11] I52XSRUH Massive cleanup, and simplification
  • [12] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [13] I24UEJQL Various post-fire fixes
  • [*] QMTANHVN Reset: only output changed files
  • [*] IIV3EL2X Cleanup, formatting, and fixing the Git feature

Change contents

  • edit in "libpijul/src/pristine/vertex.rs" at line 170
    [4.529947]
    [4.529947]
    }
    }
    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 {})
  • edit in "libpijul/src/pristine/vertex.rs" at line 206
    [4.529953]
    [4.529953]
    pub fn serialize<S: Serializer>(pos: &Position<ChangeId>, s: S) -> Result<S::Ok, S::Error> {
    let b = pos.to_base32();
    s.serialize_str(&b)
    }
  • replacement in "libpijul/src/pristine/mod.rs" at line 775
    [4.7451][4.52872:52920]()
    pub(crate) fn iter_adj_all<'txn, T: GraphTxnT>(
    [4.7451]
    [4.7504]
    pub fn iter_adj_all<'txn, T: GraphTxnT>(
  • replacement in "libpijul/src/pristine/mod.rs" at line 834
    [4.17631][4.61840:61882]()
    pub(crate) fn internal_pos<T: GraphTxnT>(
    [4.17631]
    [4.38887]
    pub fn internal_pos<T: GraphTxnT>(
  • edit in "libpijul/src/pristine/mod.rs" at line 855
    [4.39578]
    [15.3368]
    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,
    })
    }
  • edit in "libpijul/src/pristine/inode.rs" at line 42
    [4.609]
    [3.86]
    use super::Base32;
  • edit in "libpijul/src/pristine/inode.rs" at line 45
    [3.87]
    [3.87]
    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
    }
    }
    }
  • edit in "libpijul/src/pristine/inode.rs" at line 69
    [3.117][3.117:135]()
    use serde::*;
  • edit in "libpijul/src/pristine/inode.rs" at line 70
    [3.153]
    [3.153]
    use serde::*;
  • replacement in "libpijul/src/pristine/inode.rs" at line 72
    [3.154][3.154:179]()
    pub struct InodeDe{}
    [3.154]
    [3.179]
    pub struct InodeDe {}
  • replacement in "libpijul/src/pristine/inode.rs" at line 86
    [3.563][3.563:649]()
    if data_encoding::BASE32_NOPAD.decode_mut(s.as_bytes(), &mut b).is_ok() {
    [3.563]
    [3.649]
    if data_encoding::BASE32_NOPAD
    .decode_mut(s.as_bytes(), &mut b)
    .is_ok()
    {
  • replacement in "libpijul/src/pristine/inode.rs" at line 93
    [3.760][3.760:844]()
    Err(de::Error::invalid_value(serde::de::Unexpected::Str(s), &self))
    [3.760]
    [3.844]
    Err(de::Error::invalid_value(
    serde::de::Unexpected::Str(s),
    &self,
    ))
  • replacement in "libpijul/src/pristine/inode.rs" at line 102
    [3.960][3.960:997]()
    d.deserialize_str(InodeDe{})
    [3.960]
    [3.997]
    d.deserialize_str(InodeDe {})
  • replacement in "libpijul/src/pristine/edge.rs" at line 50
    [4.8950][4.8950:8996]()
    pub(crate) fn is_deleted(&self) -> bool {
    [4.8950]
    [4.8996]
    pub fn is_deleted(&self) -> bool {
  • replacement in "libpijul/src/pristine/edge.rs" at line 59
    [4.4214][4.9058:9103](),[4.9058][4.9058:9103]()
    pub(crate) fn is_parent(&self) -> bool {
    [4.4214]
    [4.9103]
    pub fn is_parent(&self) -> bool {
  • replacement in "libpijul/src/pristine/edge.rs" at line 63
    [4.9164][4.9164:9209]()
    pub(crate) fn is_folder(&self) -> bool {
    [4.9164]
    [4.9209]
    pub fn is_folder(&self) -> bool {
  • replacement in "libpijul/src/pristine/edge.rs" at line 67
    [4.9270][4.9270:9314]()
    pub(crate) fn is_block(&self) -> bool {
    [4.9270]
    [4.9314]
    pub fn is_block(&self) -> bool {
  • edit in "libpijul/src/pristine/change_id.rs" at line 2
    [16.17457]
    [4.666544]
    use byteorder::{ByteOrder, LittleEndian};
  • edit in "libpijul/src/pristine/change_id.rs" at line 47
    [4.667536]
    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)
    }
    }
  • replacement in "libpijul/src/lib.rs" at line 19
    [4.717679][4.717679:717695]()
    mod find_alive;
    [4.717679]
    [4.717710]
    pub mod find_alive;
  • edit in "libpijul/src/lib.rs" at line 341
    [4.729998]
    [4.729998]
    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)
    }
  • replacement in "libpijul/src/find_alive.rs" at line 51
    [4.32414][4.115067:115110]()
    pub(crate) fn find_alive_up<T: GraphTxnT>(
    [4.32414]
    [4.765228]
    pub fn find_alive_up<T: GraphTxnT>(
  • replacement in "libpijul/src/diff/replace.rs" at line 5
    [2.1202][2.1202:1279]()
    use crate::pristine::{ChangeId, ChangePosition, EdgeFlags, Position, Inode};
    [2.1202]
    [4.85602]
    use crate::pristine::{ChangeId, ChangePosition, EdgeFlags, Inode, Position};
  • replacement in "libpijul/src/alive/mod.rs" at line 9
    [4.995330][4.995330:995384]()
    pub(crate) use output::*;
    pub(crate) use retrieve::*;
    [4.995330]
    [4.100946]
    pub use output::*;
    pub use retrieve::*;
  • replacement in "libpijul/src/alive/mod.rs" at line 13
    [4.995463][4.995463:995495]()
    pub(crate) struct AliveVertex {
    [4.995463]
    [4.995495]
    pub struct AliveVertex {
  • replacement in "libpijul/src/alive/mod.rs" at line 16
    [4.995547][4.995547:995591]()
    children: usize,
    n_children: usize,
    [4.995547]
    [4.995591]
    pub children: usize,
    pub n_children: usize,
  • edit in "libpijul/src/alive/mod.rs" at line 21
    [4.995649]
    [4.995649]
    pub extra: Vec<(Option<SerializedEdge>, VertexId)>,
  • replacement in "libpijul/src/alive/mod.rs" at line 33
    [4.995898][4.995898:995944]()
    pub(crate) struct VertexId(pub(crate) usize);
    [4.995898]
    [4.995944]
    pub struct VertexId(pub usize);
  • replacement in "libpijul/src/alive/mod.rs" at line 36
    [4.995961][4.995961:996002]()
    const DUMMY: VertexId = VertexId(0);
    [4.995961]
    [4.996002]
    pub const DUMMY: VertexId = VertexId(0);