Struct IronShieldChallengeResponse

Source
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: i64

Implementations§

Source§

impl IronShieldChallengeResponse

Source

pub fn new(solved_challenge: IronShieldChallenge, solution: i64) -> Self

Constructor for creating a new IronShieldChallengeResponse instance.

§Arguments
  • solved_challenge: The solved ironshield challenge.
  • solution: The random nonce that correlates with solved_challenge.
§Returns
  • Self: A new correlating response with the challenge and its deciphered nonce.
Source

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.
Source

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 by concat_struct().
§Returns
  • Result<Self, String>: A result containing the parsed IronShieldChallengeResponse or an error message if parsing fails.
Source

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}"
Source

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

Source§

fn clone(&self) -> IronShieldChallengeResponse

Returns a duplicate 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 IronShieldChallengeResponse

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IronShieldChallengeResponse

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for IronShieldChallengeResponse

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,