From 45be2ff1f5bb3d6e0faa098402adf985b3d5e7ca Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 12:38:36 +0200 Subject: Rename dhall_core to dhall_syntax --- dhall_syntax/src/import.rs | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 dhall_syntax/src/import.rs (limited to 'dhall_syntax/src/import.rs') diff --git a/dhall_syntax/src/import.rs b/dhall_syntax/src/import.rs new file mode 100644 index 0000000..00f293c --- /dev/null +++ b/dhall_syntax/src/import.rs @@ -0,0 +1,64 @@ +use std::path::PathBuf; + +/// The beginning of a file path which anchors subsequent path components +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum FilePrefix { + /// Absolute path + Absolute, + /// Path relative to . + Here, + /// Path relative to .. + Parent, + /// Path relative to ~ + Home, +} + +/// The location of import (i.e. local vs. remote vs. environment) +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum ImportLocation { + Local(FilePrefix, PathBuf), + Remote(URL), + Env(String), + Missing, +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct URL { + pub scheme: Scheme, + pub authority: String, + pub path: PathBuf, + pub query: Option, + pub headers: Option>, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Scheme { + HTTP, + HTTPS, +} + +/// How to interpret the import's contents (i.e. as Dhall code or raw text) +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum ImportMode { + Code, + RawText, +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Hash { + pub protocol: String, + pub hash: String, +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ImportHashed { + pub location: ImportLocation, + pub hash: Option, +} + +/// Reference to an external resource +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Import { + pub mode: ImportMode, + pub location_hashed: ImportHashed, +} -- cgit v1.2.3