stdlib/typed_stringsView source ↗
typed_strings
23 items · generated by scribe fromstdlib/typed_strings.fd· synced 2026-11-15
Contents
- SQLString (struct)
- SQLString (impl)
- sql_query (function)
- sql_literal (function)
- sql_escape (function)
- sql_bind (function)
- sql_bind_int (function)
- ShellString (struct)
- ShellString (impl)
- shell_cmd (function)
- shell_escape (function)
- HTMLString (struct)
- HTMLString (impl)
- html_literal (function)
- html_escape (function)
- html_attr_escape (function)
- JSONString (struct)
- JSONString (impl)
- json_escape (function)
- PathString (struct)
- PathString (impl)
- path_safe (function)
- path_literal (function)
SQLString
A SQL query string. Must be constructed via sql_query() or sql_literal(). Cannot be concatenated with untrusted input — use sql_bind() for parameters.
pub struct SQLString {Fields:
| Name | Type |
|---|---|
value | str |
Defined at line 37
SQLString
impl SQLString {Defined at line 41
sql_query
Create a SQLString from a literal query string. This is the safe constructor — only use with static query text.
pub fn sql_query(sql: str) -> SQLString {Parameters:
sql:str
Returns: SQLString
Defined at line 88
sql_literal
Create a SQLString from a literal query (alias for sql_query).
pub fn sql_literal(sql: str) -> SQLString {Parameters:
sql:str
Returns: SQLString
Defined at line 95
sql_escape
Escape a string for safe inclusion in SQL. Returns a SQLString. Uses single-quote doubling (standard SQL escaping). WARNING: parameterized queries (sql_bind) are always safer than escaping.
pub fn sql_escape(input: str) -> SQLString {Parameters:
input:str
Returns: SQLString
Defined at line 104
sql_bind
Bind a parameter into a SQL query. Replaces the first ? placeholder with the string-escaped value. Returns a new SQLString. This is the safe way to include user input in SQL queries.
pub fn sql_bind(query: SQLString, param: str) -> SQLString {Parameters:
query:SQLStringparam:str
Returns: SQLString
Defined at line 114
sql_bind_int
Bind an integer parameter into a SQL query.
pub fn sql_bind_int(query: SQLString, param: i64) -> SQLString {Parameters:
query:SQLStringparam:i64
Returns: SQLString
Defined at line 123
ShellString
A shell command string. Must be constructed via shell_cmd() or shell_escape(). Prevents shell injection — untrusted input can’t be concatenated into commands.
pub struct ShellString {Fields:
| Name | Type |
|---|---|
value | str |
Defined at line 134
ShellString
impl ShellString {Defined at line 138
shell_cmd
Create a ShellString from a literal command.
pub fn shell_cmd(cmd: str) -> ShellString {Parameters:
cmd:str
Returns: ShellString
Defined at line 189
shell_escape
Escape a string for safe inclusion in a shell command. Wraps in single quotes and escapes any single quotes inside.
pub fn shell_escape(input: str) -> ShellString {Parameters:
input:str
Returns: ShellString
Defined at line 197
HTMLString
An HTML-safe string. Must be constructed via html_escape() or html_literal(). Prevents XSS — untrusted input can’t be inserted into HTML without escaping.
pub struct HTMLString {Fields:
| Name | Type |
|---|---|
value | str |
Defined at line 210
HTMLString
impl HTMLString {Defined at line 214
html_literal
Create an HTMLString from literal HTML content.
pub fn html_literal(html: str) -> HTMLString {Parameters:
html:str
Returns: HTMLString
Defined at line 229
html_escape
Escape a string for safe inclusion in HTML. Replaces &, <, >, ”, ’ with their HTML entity equivalents.
pub fn html_escape(input: str) -> HTMLString {Parameters:
input:str
Returns: HTMLString
Defined at line 237
html_attr_escape
Escape a string for safe inclusion in an HTML attribute.
pub fn html_attr_escape(input: str) -> HTMLString {Parameters:
input:str
Returns: HTMLString
Defined at line 250
JSONString
A JSON-safe string. Must be constructed via json_escape(). Prevents JSON injection — untrusted input can’t break JSON structure.
pub struct JSONString {Fields:
| Name | Type |
|---|---|
value | str |
Defined at line 264
JSONString
impl JSONString {Defined at line 268
json_escape
Escape a string for safe inclusion in JSON. Replaces ”, , and control characters with their JSON escape sequences.
pub fn json_escape(input: str) -> JSONString {Parameters:
input:str
Returns: JSONString
Defined at line 277
PathString
A filesystem path string. Must be constructed via path_safe(). Prevents path traversal — rejects ”..” and absolute paths from user input.
pub struct PathString {Fields:
| Name | Type |
|---|---|
value | str |
Defined at line 292
PathString
impl PathString {Defined at line 296
path_safe
Create a PathString from user input, rejecting path traversal attempts. Returns a PathString with empty value if the path is unsafe.
pub fn path_safe(input: str) -> PathString {Parameters:
input:str
Returns: PathString
Defined at line 314
path_literal
Create a PathString from a literal path (trusted).
pub fn path_literal(path: str) -> PathString {Parameters:
path:str
Returns: PathString
Defined at line 326
Generated by scribe, the Fides documentation generator