1use crate::strand::no_nul_bytes;
2use revision::revisioned;
3use serde::{Deserialize, Serialize};
4use std::fmt::{self, Display, Formatter};
5use std::ops::Deref;
6use std::str;
7
8#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
9#[revisioned(revision = 1)]
10pub struct Script(#[serde(with = "no_nul_bytes")] pub String);
11
12impl From<String> for Script {
13 fn from(s: String) -> Self {
14 Self(s)
15 }
16}
17
18impl From<&str> for Script {
19 fn from(s: &str) -> Self {
20 Self::from(String::from(s))
21 }
22}
23
24impl Deref for Script {
25 type Target = String;
26 fn deref(&self) -> &Self::Target {
27 &self.0
28 }
29}
30
31impl Display for Script {
32 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
33 Display::fmt(&self.0, f)
34 }
35}