pub struct SiweMessage {
pub domain: String,
pub address: String,
pub statement: Option<String>,
pub uri: String,
pub chain_id: u64,
pub nonce: String,
pub issued_at: DateTime<Utc>,
pub expiration_time: Option<DateTime<Utc>>,
pub not_before: Option<DateTime<Utc>>,
pub request_id: Option<String>,
pub resources: Vec<String>,
pub version: String,
}Expand description
A SIWE message conforming to ERC-4361.
Fields§
§domain: StringRFC 4501 dns authority (e.g., “example.com”).
address: StringEthereum address performing the signing (EIP-55 mixed-case).
statement: Option<String>Human-readable statement (optional).
uri: StringRFC 3986 URI for the signing request.
chain_id: u64EIP-155 Chain ID (1 = mainnet).
nonce: StringRandom nonce to prevent replay attacks.
issued_at: DateTime<Utc>ISO 8601 datetime when the message was issued.
expiration_time: Option<DateTime<Utc>>ISO 8601 datetime when the message expires (optional).
not_before: Option<DateTime<Utc>>ISO 8601 datetime before which the message is not valid (optional).
request_id: Option<String>System-specific request ID (optional).
resources: Vec<String>List of resources the user wishes to access (optional).
version: StringERC-4361 version (“1”).
Implementations§
Source§impl SiweMessage
impl SiweMessage
Sourcepub fn new(
domain: &str,
address: &str,
uri: &str,
chain_id: u64,
) -> Result<Self>
pub fn new( domain: &str, address: &str, uri: &str, chain_id: u64, ) -> Result<Self>
Create a new SIWE message with required fields.
Sourcepub fn to_message_string(&self) -> String
pub fn to_message_string(&self) -> String
Render the SIWE message to the ERC-4361 plaintext signing format.
Sourcepub fn message_hash(&self) -> [u8; 32]
pub fn message_hash(&self) -> [u8; 32]
Compute the EIP-191 hash of the message (SHA-256 for verification).
Trait Implementations§
Source§impl Clone for SiweMessage
impl Clone for SiweMessage
Source§fn clone(&self) -> SiweMessage
fn clone(&self) -> SiweMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SiweMessage
impl Debug for SiweMessage
Source§impl<'de> Deserialize<'de> for SiweMessage
impl<'de> Deserialize<'de> for SiweMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SiweMessage
impl RefUnwindSafe for SiweMessage
impl Send for SiweMessage
impl Sync for SiweMessage
impl Unpin for SiweMessage
impl UnsafeUnpin for SiweMessage
impl UnwindSafe for SiweMessage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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