1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use std::path::{Path, PathBuf}; use crate::Hash; /// Represents the types of session or payment code. pub enum Code { /// The filesystem path of compiled Wasm code. Path(PathBuf), /// A named key providing the location of a stored contract. NamedKey(String, String), /// A hash providing the location of a stored contract. Hash(Hash, String), } // Note: can't just `impl<T: AsRef<Path>> From<T> for Code` because the compiler complains about // a conflicting implementation of `From<URef>` - as URef could be made `AsRef<Path>` in the future impl<'a> From<&'a str> for Code { fn from(path: &'a str) -> Code { Code::Path(path.into()) } } impl<'a> From<&'a Path> for Code { fn from(path: &'a Path) -> Code { Code::Path(path.into()) } } impl From<PathBuf> for Code { fn from(path: PathBuf) -> Code { Code::Path(path) } }