graph_builder/input/
mod.rs1pub mod binary;
2#[cfg(feature = "dotgraph")]
3#[cfg_attr(all(feature = "dotgraph", has_doc_cfg), doc(cfg(feature = "dotgraph")))]
4pub mod dotgraph;
5pub mod edgelist;
6#[cfg(feature = "gdl")]
7#[cfg_attr(all(feature = "gdl", has_doc_cfg), doc(cfg(feature = "gdl")))]
8pub mod gdl;
9pub mod graph500;
10
11pub use binary::BinaryInput;
12#[cfg(feature = "dotgraph")]
13pub use dotgraph::DotGraph;
14#[cfg(feature = "dotgraph")]
15pub use dotgraph::DotGraphInput;
16pub use edgelist::EdgeList;
17pub use edgelist::EdgeListInput;
18pub use edgelist::Edges;
19pub use graph500::Graph500;
20pub use graph500::Graph500Input;
21
22use crate::index::Idx;
23
24pub struct InputPath<P>(pub(crate) P);
25
26pub trait InputCapabilities<NI: Idx> {
27 type GraphInput;
28}
29
30#[derive(Debug, Clone, Copy)]
31pub enum Direction {
32 Outgoing,
33 Incoming,
34 Undirected,
35}
36
37pub trait ParseValue: Default + Sized {
39 fn parse(bytes: &[u8]) -> (Self, usize);
59}
60
61impl ParseValue for () {
62 fn parse(_bytes: &[u8]) -> (Self, usize) {
63 ((), 0)
64 }
65}
66
67macro_rules! impl_parse_value {
68 ($atoi:path, $($ty:ty),+ $(,)?) => {
69 $(
70 impl $crate::input::ParseValue for $ty {
71 fn parse(bytes: &[u8]) -> (Self, usize) {
72 if bytes.len() == 0 {
73 (<$ty as ::std::default::Default>::default(), 0)
74 } else {
75 $atoi(bytes)
76 }
77 }
78 }
79 )+
80 };
81}
82
83impl_parse_value!(
84 ::atoi::FromRadix10::from_radix_10,
85 u8,
86 u16,
87 u32,
88 u64,
89 u128,
90 usize,
91);
92
93impl_parse_value!(
94 ::atoi::FromRadix10Signed::from_radix_10_signed,
95 i8,
96 i16,
97 i32,
98 i64,
99 i128,
100 isize,
101);
102
103impl_parse_value!(parse_float, f32, f64);
104
105fn parse_float<T: fast_float2::FastFloat>(bytes: &[u8]) -> (T, usize) {
106 fast_float2::parse_partial(bytes).unwrap()
107}