2023-05-09 17:48:14 +00:00
|
|
|
use crate::sql::strand::no_nul_bytes;
|
2023-08-17 18:03:46 +00:00
|
|
|
use revision::revisioned;
|
2022-01-13 17:36:41 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-10-04 21:51:18 +00:00
|
|
|
use std::fmt::{self, Display, Formatter};
|
2022-05-04 21:40:41 +00:00
|
|
|
use std::ops::Deref;
|
2022-01-13 17:36:41 +00:00
|
|
|
use std::str;
|
|
|
|
|
2022-10-27 12:23:24 +00:00
|
|
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
2023-08-17 18:03:46 +00:00
|
|
|
#[revisioned(revision = 1)]
|
2024-01-09 15:34:52 +00:00
|
|
|
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
2023-05-09 17:48:14 +00:00
|
|
|
pub struct Script(#[serde(with = "no_nul_bytes")] pub String);
|
2022-05-04 21:40:41 +00:00
|
|
|
|
2022-05-20 21:16:25 +00:00
|
|
|
impl From<String> for Script {
|
|
|
|
fn from(s: String) -> Self {
|
2022-10-04 21:51:18 +00:00
|
|
|
Self(s)
|
2022-05-20 21:16:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-25 09:42:10 +00:00
|
|
|
impl From<&str> for Script {
|
2022-05-20 21:16:25 +00:00
|
|
|
fn from(s: &str) -> Self {
|
2022-10-04 21:51:18 +00:00
|
|
|
Self::from(String::from(s))
|
2022-05-20 21:16:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-04 21:40:41 +00:00
|
|
|
impl Deref for Script {
|
|
|
|
type Target = String;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
2022-01-13 17:36:41 +00:00
|
|
|
}
|
|
|
|
|
2022-10-04 21:51:18 +00:00
|
|
|
impl Display for Script {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
Display::fmt(&self.0, f)
|
2022-01-13 17:36:41 +00:00
|
|
|
}
|
|
|
|
}
|