summaryrefslogtreecommitdiff
path: root/dhall_core/src/printer.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-24 16:25:37 +0100
committerNadrieril2019-03-24 16:25:37 +0100
commit8bae9a8fab523668e9aea96e4f32cec21e22998a (patch)
tree09763096bd270981978152226f9b780dbd22153b /dhall_core/src/printer.rs
parent6c1a739687f706cf6630c55f8d53c92aacaf6e3d (diff)
Parser import hash and headers
Diffstat (limited to '')
-rw-r--r--dhall_core/src/printer.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs
index 9525904..1d1b063 100644
--- a/dhall_core/src/printer.rs
+++ b/dhall_core/src/printer.rs
@@ -326,12 +326,16 @@ impl Display for Label {
}
}
-impl Display for Import {
+impl Display for Hash {
+ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ write!(f, "{}:{}", self.protocol, self.hash)
+ }
+}
+impl Display for ImportHashed {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use std::path::PathBuf;
use FilePrefix::*;
use ImportLocation::*;
- use ImportMode::*;
let quoted = |s: &str| -> String {
if s.chars().all(|c| c.is_ascii_alphanumeric()) {
s.to_owned()
@@ -364,6 +368,9 @@ impl Display for Import {
if let Some(q) = &url.query {
write!(f, "?{}", q)?
}
+ if let Some(h) = &url.headers {
+ write!(f, " using ({})", h)?
+ }
}
Env(e) => {
write!(f, "env:{}", quoted(e))?;
@@ -372,6 +379,18 @@ impl Display for Import {
write!(f, "missing")?;
}
}
+ if let Some(hash) = &self.hash {
+ write!(f, " ")?;
+ hash.fmt(f)?;
+ }
+ Ok(())
+ }
+}
+
+impl Display for Import {
+ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ self.location_hashed.fmt(f)?;
+ use ImportMode::*;
match self.mode {
Code => {}
RawText => write!(f, " as Text")?,