pub struct HtmlFormData(/* private fields */);
Expand description

HTML Form Data.

https://cloud.google.com/storage/docs/xml-api/post-object-forms

§Example (full)

use cloud_storage_signature::HtmlFormData;
use cloud_storage_signature::PolicyDocumentSigningOptions;
use cloud_storage_signature::SigningKey;
let form_data = HtmlFormData::builder()
    .acl("public-read")
    .bucket("example-bucket")
    .cache_control("max-age=3600")
    .content_disposition("attachment")
    .content_encoding("gzip")
    .content_length(1024)
    .content_type("application/octet-stream")
    .expires("2022-01-04T00:00:00Z")
    .key("example-object")
    .success_action_redirect("https://example.com/success")
    .success_action_status(201)
    .x_goog_custom_time("2022-01-03T00:00:00Z")
    .x_goog_meta("reviewer", "jane")
    .x_goog_meta("project-manager", "john")
    .policy_document_signing_options(PolicyDocumentSigningOptions {
        accessible_at: None,
        expiration: std::time::SystemTime::now() + std::time::Duration::from_secs(60 * 60),
        region: None,
        signing_key: SigningKey::service_account(
            service_account_client_email.to_string(),
            service_account_private_key.to_string(),
        ),
        use_sign_blob: false,
    })
    .build()
    .await?;
assert_eq!(
  form_data.into_vec().into_iter().map(|(n, _)| n).collect::<Vec<String>>(),
  [
    "acl",
    "bucket",
    "Cache-Control",
    "Content-Disposition",
    "Content-Encoding",
    "Content-Length",
    "Content-Type",
    "Expires",
    "key",
    "policy",
    "success_action_redirect",
    "success_action_status",
    "x-goog-algorithm",
    "x-goog-credential",
    "x-goog-custom-time",
    "x-goog-date",
    "x-goog-signature",
    "x-goog-meta-reviewer",
    "x-goog-meta-project-manager",
  ].into_iter().map(|n| n.to_string()).collect::<Vec<String>>()
);

§Example (minimal)

use cloud_storage_signature::HtmlFormData;
assert_eq!(
    HtmlFormData::builder()
        .key("object_name1")
        .build()
        .await?
        .into_vec(),
    vec![("key".to_string(), "object_name1".to_string())]
);

§Example (policy document minimal)

use cloud_storage_signature::HtmlFormData;
use cloud_storage_signature::PolicyDocumentSigningOptions;
use cloud_storage_signature::SigningKey;
let form_data = HtmlFormData::builder()
    .bucket("example-bucket")
    .key("example-object")
    .policy_document_signing_options(PolicyDocumentSigningOptions {
        accessible_at: None,
        expiration: std::time::SystemTime::now() + std::time::Duration::from_secs(60 * 60),
        region: None,
        signing_key: SigningKey::service_account(
            service_account_client_email.to_string(),
            service_account_private_key.to_string()
        ),
        use_sign_blob: false,
    })
    .build()
    .await?;
assert_eq!(
  form_data.into_vec().into_iter().map(|(n, _)| n).collect::<Vec<String>>(),
  [
    "bucket",
    "key",
    "policy",
    "x-goog-algorithm",
    "x-goog-credential",
    "x-goog-date",
    "x-goog-signature",
  ].into_iter().map(|n| n.to_string()).collect::<Vec<String>>()
);

Implementations§

source§

impl HtmlFormData

source

pub fn builder() -> HtmlFormDataBuilder

Returns a new HtmlFormDataBuilder.

source

pub fn into_vec(self) -> Vec<(String, String)>

Converts self into a Vec<(String, String)>. The first element of each tuple is the field name, and the second element is the field value.

Trait Implementations§

source§

impl Clone for HtmlFormData

source§

fn clone(&self) -> HtmlFormData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HtmlFormData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more