Struct VersionHistory
pub struct VersionHistory { /* private fields */ }Expand description
The complete history of this endpoint as far as Ruma knows, together with all variants on versions stable and unstable.
The amount and positioning of path variables are the same over all path variants.
Implementations§
§impl VersionHistory
impl VersionHistory
pub const fn new(
unstable_paths: &'static [(Option<&'static str>, &'static str)],
stable_paths: &'static [(StablePathSelector, &'static str)],
deprecated: Option<MatrixVersion>,
removed: Option<MatrixVersion>,
) -> VersionHistory
pub const fn new( unstable_paths: &'static [(Option<&'static str>, &'static str)], stable_paths: &'static [(StablePathSelector, &'static str)], deprecated: Option<MatrixVersion>, removed: Option<MatrixVersion>, ) -> VersionHistory
Constructs an instance of VersionHistory, erroring on compilation if it does not
pass invariants.
Specifically, this checks the following invariants:
- Path arguments are equal (in order, amount, and argument name) in all path strings
- In
stable_paths:- Matrix versions are in ascending order
- No matrix version is referenced twice
deprecated’s version comes after the latest version mentioned instable_paths, except for version 1.0, and only if any stable path is definedremovedcomes afterdeprecated, or after the latest referencedstable_paths, likedeprecated
§Arguments
unstable_paths- List of unstable paths for the endpoint, mapped to optional unstable features.stable_paths- List of stable paths for the endpoint, mapped to selectors.deprecated- The Matrix version that deprecated the endpoint, if any.removed- The Matrix version that removed the endpoint, if any.
pub fn is_supported(&self, considering: &SupportedVersions) -> bool
pub fn is_supported(&self, considering: &SupportedVersions) -> bool
Whether the homeserver advertises support for a path in this VersionHistory.
Returns true if any version or feature in the given SupportedVersions matches a path
in this history, unless the endpoint was removed.
Note that this is likely to return false negatives, since some endpoints don’t specify a stable or unstable feature, and homeservers should not advertise support for a Matrix version unless they support all of its features.
pub fn versioning_decision_for(
&self,
versions: &BTreeSet<MatrixVersion>,
) -> VersioningDecision
pub fn versioning_decision_for( &self, versions: &BTreeSet<MatrixVersion>, ) -> VersioningDecision
Decide which kind of endpoint to use given the supported versions of a homeserver.
Returns:
Removedif the endpoint is removed in all supported versions.Versionif the endpoint is stable or deprecated in at least one supported version.Featurein all other cases, to look if a feature path is supported, or use the last unstable path as a fallback.
If resulting VersioningDecision is Stable, it will also detail if any version denoted
deprecation or removal.
pub fn added_in(&self) -> Option<MatrixVersion>
pub fn added_in(&self) -> Option<MatrixVersion>
Returns the first version this endpoint was added in.
Is None when this endpoint is unstable/unreleased.
pub fn deprecated_in(&self) -> Option<MatrixVersion>
pub fn deprecated_in(&self) -> Option<MatrixVersion>
Returns the Matrix version that deprecated this endpoint, if any.
pub fn removed_in(&self) -> Option<MatrixVersion>
pub fn removed_in(&self) -> Option<MatrixVersion>
Returns the Matrix version that removed this endpoint, if any.
pub fn unstable_paths(
&self,
) -> impl Iterator<Item = (Option<&'static str>, &'static str)>
pub fn unstable_paths( &self, ) -> impl Iterator<Item = (Option<&'static str>, &'static str)>
Returns all unstable path variants in canon form, with optional corresponding feature.
pub fn stable_paths(
&self,
) -> impl Iterator<Item = (StablePathSelector, &'static str)>
pub fn stable_paths( &self, ) -> impl Iterator<Item = (StablePathSelector, &'static str)>
Returns all version path variants in canon form, with corresponding selector.
pub fn version_path(
&self,
versions: &BTreeSet<MatrixVersion>,
) -> Option<&'static str>
pub fn version_path( &self, versions: &BTreeSet<MatrixVersion>, ) -> Option<&'static str>
The path that should be used to query the endpoint, given a set of supported versions.
Picks the latest path that the versions accept.
Returns an endpoint in the following format;
/_matrix/client/versions/_matrix/client/hello/{world}({world}is a path replacement parameter)
Note: This doesn’t handle endpoint removals, check with
versioning_decision_for to see if this endpoint
is still available.
pub fn feature_path(
&self,
supported_features: &BTreeSet<FeatureFlag>,
) -> Option<&'static str>
pub fn feature_path( &self, supported_features: &BTreeSet<FeatureFlag>, ) -> Option<&'static str>
The path that should be used to query the endpoint, given a list of supported features.
Trait Implementations§
§impl Clone for VersionHistory
impl Clone for VersionHistory
§fn clone(&self) -> VersionHistory
fn clone(&self) -> VersionHistory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for VersionHistory
impl Debug for VersionHistory
§impl PartialEq for VersionHistory
impl PartialEq for VersionHistory
§impl PathBuilder for VersionHistory
impl PathBuilder for VersionHistory
§fn select_path(
&self,
input: Cow<'_, SupportedVersions>,
) -> Result<&'static str, IntoHttpError>
fn select_path( &self, input: Cow<'_, SupportedVersions>, ) -> Result<&'static str, IntoHttpError>
Pick the right path according to the given input.
This will fail if, for every version in input;
- The endpoint is too old, and has been removed in all versions.
(
EndpointRemoved) - The endpoint is too new, and no unstable path is known for this endpoint.
(
NoUnstablePath)
Finally, this will emit a warning through [tracing] if it detects that any version in
input has deprecated this endpoint.
§type Input<'a> = Cow<'a, SupportedVersions>
type Input<'a> = Cow<'a, SupportedVersions>
§fn all_paths(&self) -> impl Iterator<Item = &'static str>
fn all_paths(&self) -> impl Iterator<Item = &'static str>
§fn make_endpoint_url(
&self,
input: Self::Input<'_>,
base_url: &str,
path_args: &[&dyn Display],
query_string: &str,
) -> Result<String, IntoHttpError>
fn make_endpoint_url( &self, input: Self::Input<'_>, base_url: &str, path_args: &[&dyn Display], query_string: &str, ) -> Result<String, IntoHttpError>
impl Eq for VersionHistory
impl StructuralPartialEq for VersionHistory
Auto Trait Implementations§
impl Freeze for VersionHistory
impl RefUnwindSafe for VersionHistory
impl Send for VersionHistory
impl Sync for VersionHistory
impl Unpin for VersionHistory
impl UnwindSafe for VersionHistory
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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