From 8bae9a8fab523668e9aea96e4f32cec21e22998a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 24 Mar 2019 16:25:37 +0100 Subject: Parser import hash and headers --- dhall_core/src/printer.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'dhall_core/src/printer.rs') 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")?, -- cgit v1.2.3