pub struct IronShieldChallengeResponse {
pub solved_challenge: IronShieldChallenge,
pub solution: i64,
}Expand description
IronShield Challenge Response structure
solved_challenge: The complete original IronShieldChallenge that was solved.solution: The nonce solution found by the proof-of-work algorithm.
Fields§
§solved_challenge: IronShieldChallenge§solution: i64Implementations§
Source§impl IronShieldChallengeResponse
impl IronShieldChallengeResponse
Sourcepub fn new(solved_challenge: IronShieldChallenge, solution: i64) -> Self
pub fn new(solved_challenge: IronShieldChallenge, solution: i64) -> Self
Sourcepub fn concat_struct(&self) -> String
pub fn concat_struct(&self) -> String
Concatenates the response data into a string.
Concatenates:
solved_challenge: As its concatenated string representation.solution: 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 IronShieldChallengeResponse from a concatenated string.
This function reverses the operation of
IronShieldChallengeResponse::concat_struct.
Expects a string in the format: “challenge_concat_string|solution”.
§Arguments
concat_string: The concatenated string to parse, typically generated byconcat_struct().
§Returns
Result<Self, String>: A result containing the parsedIronShieldChallengeResponseor 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::{IronShieldChallengeResponse, IronShieldChallenge, SigningKey};
let dummy_key = SigningKey::from_bytes(&[0u8; 32]);
let challenge = IronShieldChallenge::new("test".to_string(), 100_000, dummy_key, [0x34; 32]);
let response = IronShieldChallengeResponse::new(challenge, 12345);
let header_value = response.to_base64url_header();
// Use header_value in HTTP header: "X-IronShield-Challenge-Response: {header_value}"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::{IronShieldChallengeResponse, IronShieldChallenge, SigningKey};
// Create a response and encode it
let dummy_key = SigningKey::from_bytes(&[0u8; 32]);
let challenge = IronShieldChallenge::new("test".to_string(), 100_000, dummy_key, [0x34; 32]);
let original = IronShieldChallengeResponse::new(challenge, 12345);
let header_value = original.to_base64url_header();
// Decode it back
let decoded = IronShieldChallengeResponse::from_base64url_header(&header_value).unwrap();
assert_eq!(original.solution, decoded.solution);Trait Implementations§
Source§impl Clone for IronShieldChallengeResponse
impl Clone for IronShieldChallengeResponse
Source§fn clone(&self) -> IronShieldChallengeResponse
fn clone(&self) -> IronShieldChallengeResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more