forked from packages/digest_auth_rs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
405 B
19 lines
405 B
6 years ago
|
use std::string::ToString;
|
||
|
|
||
|
/// slash quoting for digest strings
|
||
|
pub trait QuoteForDigest {
|
||
|
fn quote_for_digest(&self) -> String;
|
||
|
}
|
||
|
|
||
|
impl QuoteForDigest for &str {
|
||
|
fn quote_for_digest(&self) -> String {
|
||
|
self.to_string().quote_for_digest()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl QuoteForDigest for String {
|
||
|
fn quote_for_digest(&self) -> String {
|
||
|
self.replace("\\", "\\\\").replace("\"", "\\\"")
|
||
|
}
|
||
|
}
|