pub struct SignedWatermarkParams {
pub url: String,
pub position: Option<String>,
pub opacity: Option<u8>,
pub margin: Option<u32>,
}Expand description
Builds a signed public transform URL for the server adapter.
The resulting URL targets either GET /images/by-path or GET /images/by-url depending on
source. base_url must be an absolute http or https URL that points at the externally
visible server origin. The helper applies the same canonical query and HMAC-SHA256 signature
scheme that the server adapter verifies at request time.
The helper serializes only explicitly requested transform options and omits fields that would resolve to the documented defaults on the server side.
§Errors
Returns an error string when base_url is not an absolute http or https URL, when the
visible authority cannot be determined, or when the HMAC state cannot be initialized.
§Examples
use truss::adapters::server::{sign_public_url, SignedUrlSource};
use truss::{MediaType, TransformOptions};
let url = sign_public_url(
"https://cdn.example.com",
SignedUrlSource::Path {
path: "/image.png".to_string(),
version: None,
},
&TransformOptions {
format: Some(MediaType::Jpeg),
..TransformOptions::default()
},
"public-dev",
"secret-value",
4_102_444_800,
None,
None,
)
.unwrap();
assert!(url.starts_with("https://cdn.example.com/images/by-path?"));
assert!(url.contains("keyId=public-dev"));
assert!(url.contains("signature="));Optional watermark parameters for signed URL generation.
Fields§
§url: String§position: Option<String>§opacity: Option<u8>§margin: Option<u32>Trait Implementations§
Source§impl Debug for SignedWatermarkParams
impl Debug for SignedWatermarkParams
Source§impl Default for SignedWatermarkParams
impl Default for SignedWatermarkParams
Source§fn default() -> SignedWatermarkParams
fn default() -> SignedWatermarkParams
Auto Trait Implementations§
impl Freeze for SignedWatermarkParams
impl RefUnwindSafe for SignedWatermarkParams
impl Send for SignedWatermarkParams
impl Sync for SignedWatermarkParams
impl Unpin for SignedWatermarkParams
impl UnsafeUnpin for SignedWatermarkParams
impl UnwindSafe for SignedWatermarkParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more