Struct XMatrix
#[non_exhaustive]pub struct XMatrix {
pub origin: OwnedServerName,
pub destination: Option<OwnedServerName>,
pub key: OwnedKeyId<SigningKeyAlgorithm, ServerSigningKeyVersion>,
pub sig: Base64,
}Expand description
Typed representation of an Authorization header of scheme X-Matrix, as defined in the
Matrix Server-Server API.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.origin: OwnedServerNameThe server name of the sending server.
destination: Option<OwnedServerName>The server name of the receiving sender.
For compatibility with older servers, recipients should accept requests without this parameter, but MUST always send it. If this property is included, but the value does not match the receiving server’s name, the receiving server must deny the request with an HTTP status code 401 Unauthorized.
key: OwnedKeyId<SigningKeyAlgorithm, ServerSigningKeyVersion>The ID - including the algorithm name - of the sending server’s key that was used to sign the request.
sig: Base64The signature of the JSON.
Implementations§
§impl XMatrix
impl XMatrix
pub fn new(
origin: OwnedServerName,
destination: OwnedServerName,
key: OwnedKeyId<SigningKeyAlgorithm, ServerSigningKeyVersion>,
sig: Base64,
) -> XMatrix
pub fn new( origin: OwnedServerName, destination: OwnedServerName, key: OwnedKeyId<SigningKeyAlgorithm, ServerSigningKeyVersion>, sig: Base64, ) -> XMatrix
Construct a new X-Matrix Authorization header.
pub fn parse(s: impl AsRef<str>) -> Result<XMatrix, XMatrixParseError>
pub fn parse(s: impl AsRef<str>) -> Result<XMatrix, XMatrixParseError>
Parse an X-Matrix Authorization header from the given string.
pub fn request_object<T>(
request: &Request<T>,
origin: &ServerName,
destination: &ServerName,
) -> Result<BTreeMap<String, CanonicalJsonValue>, Error>
pub fn request_object<T>( request: &Request<T>, origin: &ServerName, destination: &ServerName, ) -> Result<BTreeMap<String, CanonicalJsonValue>, Error>
Construct the canonical JSON object representation of the request to sign for the XMatrix
scheme.
pub fn try_from_http_request<T>(
request: &Request<T>,
input: ServerSignaturesInput<'_>,
) -> Result<XMatrix, XMatrixFromRequestError>
pub fn try_from_http_request<T>( request: &Request<T>, input: ServerSignaturesInput<'_>, ) -> Result<XMatrix, XMatrixFromRequestError>
Try to construct this header from the given HTTP request and input.
pub fn verify_request<T>(
&self,
request: &Request<T>,
destination: &ServerName,
public_key_map: &BTreeMap<String, BTreeMap<String, Base64>>,
) -> Result<(), XMatrixVerificationError>
pub fn verify_request<T>( &self, request: &Request<T>, destination: &ServerName, public_key_map: &BTreeMap<String, BTreeMap<String, Base64>>, ) -> Result<(), XMatrixVerificationError>
Verify that the signature in the sig field is valid for the given incoming HTTP request,
with the given public keys map from the origin.
Trait Implementations§
§impl Credentials for XMatrix
impl Credentials for XMatrix
§impl From<&XMatrix> for HeaderValue
impl From<&XMatrix> for HeaderValue
§fn from(value: &XMatrix) -> HeaderValue
fn from(value: &XMatrix) -> HeaderValue
§impl TryFrom<&HeaderValue> for XMatrix
impl TryFrom<&HeaderValue> for XMatrix
§type Error = XMatrixParseError
type Error = XMatrixParseError
§fn try_from(
value: &HeaderValue,
) -> Result<XMatrix, <XMatrix as TryFrom<&HeaderValue>>::Error>
fn try_from( value: &HeaderValue, ) -> Result<XMatrix, <XMatrix as TryFrom<&HeaderValue>>::Error>
Auto Trait Implementations§
impl Freeze for XMatrix
impl RefUnwindSafe for XMatrix
impl Send for XMatrix
impl Sync for XMatrix
impl Unpin for XMatrix
impl UnwindSafe for XMatrix
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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