pub struct IronShieldRequest {
pub endpoint: String,
pub timestamp: i64,
}Expand description
endpoint: The endpoint URL for the request.timestamp: The timestamp of the request in unix millis.
Fields§
§endpoint: StringThe protected endpoint URL (must be HTTPS)
timestamp: i64Request timestamp in Unix milliseconds (use Date.now() in JavaScript)
Implementations§
Source§impl IronShieldRequest
impl IronShieldRequest
Sourcepub fn new(endpoint: String, timestamp: i64) -> Self
pub fn new(endpoint: String, timestamp: i64) -> Self
Constructor for creating a new IronShieldRequest instance.
Sourcepub fn concat_struct(&self) -> String
pub fn concat_struct(&self) -> String
Concatenates the request data into a string.
Concatenates:
endpoint: as a string.timestamp: as a string.
Sourcepub fn from_concat_struct(concat_string: &str) -> Result<Self, String>
pub fn from_concat_struct(concat_string: &str) -> Result<Self, String>
Creates an IronShieldRequest from a concatenated string.
This function reverses the operation of
IronShieldRequest::concat_struct.
Expects a string in the format: “endpoint|timestamp”.
§Arguments
concat_string: The concatenated string to parse, typically generated byconcat_struct().
§Returns
Result<Self, String>: A result containing the parsedIronShieldRequestor an error message if parsing fails.
Sourcepub fn to_base64url_header(&self) -> String
pub fn to_base64url_header(&self) -> String
Encodes the response as a base64url string for HTTP header transport.
This method concatenates all response fields using the established | delimiter
format, and then base64url-encodes the result for safe transport in HTTP headers.
§Returns
String: Base64url-encoded string ready for HTTP header use
§Example
use ironshield_types::IronShieldRequest;
let request = IronShieldRequest::new("https://example.com/api".to_string(), 123456789);
let header_value = request.to_base64url_header();Sourcepub fn from_base64url_header(encoded_header: &str) -> Result<Self, String>
pub fn from_base64url_header(encoded_header: &str) -> Result<Self, String>
Decodes a base64url-encoded response from an HTTP header.
This method reverses the to_base64url_header() operation by first base64url-decoding
the input string and then parsing it using the established | delimiter format.
§Arguments
encoded_header: The base64url-encoded string from the HTTP header.
§Returns
Result<Self, String>: Decoded response or detailed error message.
§Example
use ironshield_types::IronShieldRequest;
// Create a response and encode it.
let original = IronShieldRequest::new("https://example.com/api".to_string(), 123456789);
let header_value = original.to_base64url_header();
// Decode it back.
let decoded = IronShieldRequest::from_base64url_header(&header_value).unwrap();
assert_eq!(original.endpoint, decoded.endpoint);Trait Implementations§
Source§impl Clone for IronShieldRequest
impl Clone for IronShieldRequest
Source§fn clone(&self) -> IronShieldRequest
fn clone(&self) -> IronShieldRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more