Skip to main content

surrealdb_sql/
script.rs

1use std::ops::Deref;
2
3use surrealdb_types::{SqlFormat, ToSql};
4
5#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Hash)]
6#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7pub struct Script(#[cfg_attr(feature = "arbitrary", arbitrary(default))] pub String);
8
9impl Deref for Script {
10	type Target = String;
11	fn deref(&self) -> &Self::Target {
12		&self.0
13	}
14}
15
16impl ToSql for Script {
17	fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
18		self.0.fmt_sql(f, fmt)
19	}
20}
21
22impl From<String> for Script {
23	fn from(s: String) -> Self {
24		Self(s)
25	}
26}
27
28impl From<&str> for Script {
29	fn from(s: &str) -> Self {
30		Self::from(String::from(s))
31	}
32}