From 55cad7251ecdda15989842d3b686e46d0b42df0e Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 6 Nov 2022 21:49:49 -0800 Subject: pds: wrangle 'iroh_car' in to PDS code --- adenosine-pds/src/vendored/iroh_car/error.rs | 3 ++- adenosine-pds/src/vendored/iroh_car/header.rs | 15 ++++++++------- adenosine-pds/src/vendored/iroh_car/mod.rs | 10 ++++++++++ adenosine-pds/src/vendored/iroh_car/reader.rs | 10 +++++----- adenosine-pds/src/vendored/iroh_car/util.rs | 2 +- adenosine-pds/src/vendored/iroh_car/writer.rs | 4 ++-- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 adenosine-pds/src/vendored/iroh_car/mod.rs (limited to 'adenosine-pds/src/vendored') diff --git a/adenosine-pds/src/vendored/iroh_car/error.rs b/adenosine-pds/src/vendored/iroh_car/error.rs index 3579413..1edcefe 100644 --- a/adenosine-pds/src/vendored/iroh_car/error.rs +++ b/adenosine-pds/src/vendored/iroh_car/error.rs @@ -1,3 +1,4 @@ +use libipld::cid; use thiserror::Error; /// Car utility error @@ -10,7 +11,7 @@ pub enum Error { #[error("Io error: {0}")] Io(#[from] std::io::Error), #[error("Cbor encoding error: {0}")] - Cbor(#[from] ipld::error::Error), + Cbor(#[from] libipld::error::Error), #[error("ld read too large {0}")] LdReadTooLarge(usize), } diff --git a/adenosine-pds/src/vendored/iroh_car/header.rs b/adenosine-pds/src/vendored/iroh_car/header.rs index c004e35..051d2cc 100644 --- a/adenosine-pds/src/vendored/iroh_car/header.rs +++ b/adenosine-pds/src/vendored/iroh_car/header.rs @@ -1,8 +1,9 @@ -use cid::Cid; -use ipld::codec::Codec; -use ipld_cbor::DagCborCodec; +use libipld::cbor::DagCborCodec; +use libipld::codec::Codec; +use libipld::ipld; +use libipld::Cid; -use crate::error::Error; +use super::error::Error; /// A car header. #[derive(Debug, Clone, PartialEq, Eq)] @@ -57,7 +58,7 @@ impl CarHeader { } /// CAR file header version 1. -#[derive(Debug, Clone, Default, ipld::DagCbor, PartialEq, Eq)] +#[derive(Debug, Clone, Default, libipld::DagCbor, PartialEq, Eq)] pub struct CarHeaderV1 { #[ipld] pub roots: Vec, @@ -80,8 +81,8 @@ impl From> for CarHeaderV1 { #[cfg(test)] mod tests { - use ipld::codec::{Decode, Encode}; - use ipld_cbor::DagCborCodec; + use libipld::cbor::DagCborCodec; + use libipld::codec::{Decode, Encode}; use multihash::MultihashDigest; use super::*; diff --git a/adenosine-pds/src/vendored/iroh_car/mod.rs b/adenosine-pds/src/vendored/iroh_car/mod.rs new file mode 100644 index 0000000..b40e046 --- /dev/null +++ b/adenosine-pds/src/vendored/iroh_car/mod.rs @@ -0,0 +1,10 @@ +/// Module version of lib.rs +mod error; +mod header; +mod reader; +mod util; +mod writer; + +pub use header::CarHeader; +pub use reader::CarReader; +pub use writer::CarWriter; diff --git a/adenosine-pds/src/vendored/iroh_car/reader.rs b/adenosine-pds/src/vendored/iroh_car/reader.rs index c0209be..916f27e 100644 --- a/adenosine-pds/src/vendored/iroh_car/reader.rs +++ b/adenosine-pds/src/vendored/iroh_car/reader.rs @@ -1,8 +1,8 @@ -use cid::Cid; use futures::Stream; +use libipld::Cid; use tokio::io::AsyncRead; -use crate::{ +use super::{ error::Error, header::CarHeader, util::{ld_read, read_node}, @@ -61,12 +61,12 @@ where mod tests { use std::io::Cursor; - use cid::Cid; use futures::TryStreamExt; - use ipld_cbor::DagCborCodec; + use libipld::cbor::DagCborCodec; + use libipld::Cid; use multihash::MultihashDigest; - use crate::{header::CarHeaderV1, writer::CarWriter}; + use super::super::{header::CarHeaderV1, writer::CarWriter}; use super::*; diff --git a/adenosine-pds/src/vendored/iroh_car/util.rs b/adenosine-pds/src/vendored/iroh_car/util.rs index 25be761..90435b1 100644 --- a/adenosine-pds/src/vendored/iroh_car/util.rs +++ b/adenosine-pds/src/vendored/iroh_car/util.rs @@ -1,5 +1,5 @@ -use cid::Cid; use integer_encoding::VarIntAsyncReader; +use libipld::Cid; use tokio::io::{AsyncRead, AsyncReadExt}; use super::error::Error; diff --git a/adenosine-pds/src/vendored/iroh_car/writer.rs b/adenosine-pds/src/vendored/iroh_car/writer.rs index 9f17eb9..4299b5d 100644 --- a/adenosine-pds/src/vendored/iroh_car/writer.rs +++ b/adenosine-pds/src/vendored/iroh_car/writer.rs @@ -1,8 +1,8 @@ -use cid::Cid; use integer_encoding::VarIntAsyncWriter; +use libipld::Cid; use tokio::io::{AsyncWrite, AsyncWriteExt}; -use crate::{error::Error, header::CarHeader}; +use super::{error::Error, header::CarHeader}; #[derive(Debug)] pub struct CarWriter { -- cgit v1.2.3