690dd55a86
Co-authored-by: Gerard Guillemas Martos <gerard.guillemas@surrealdb.com>
36 lines
804 B
Rust
36 lines
804 B
Rust
use crate::sql::strand::no_nul_bytes;
|
|
use revision::revisioned;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::fmt::{self, Display, Formatter};
|
|
use std::ops::Deref;
|
|
use std::str;
|
|
|
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
|
#[revisioned(revision = 1)]
|
|
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
|
pub struct Script(#[serde(with = "no_nul_bytes")] pub String);
|
|
|
|
impl From<String> for Script {
|
|
fn from(s: String) -> Self {
|
|
Self(s)
|
|
}
|
|
}
|
|
|
|
impl From<&str> for Script {
|
|
fn from(s: &str) -> Self {
|
|
Self::from(String::from(s))
|
|
}
|
|
}
|
|
|
|
impl Deref for Script {
|
|
type Target = String;
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl Display for Script {
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
Display::fmt(&self.0, f)
|
|
}
|
|
}
|