Struct MockEndpoint

Source
pub struct MockEndpoint<'a, T> { /* private fields */ }
Available on crate feature testing and non-target_family="wasm" only.
Expand description

Generic mocked endpoint, with useful common helpers.

Implementations§

Source§

impl<'a> MockEndpoint<'a, ServerMetadataEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful metadata response with all the supported endpoints.

Source

pub fn ok_https(self) -> MatrixMock<'a>

Returns a successful metadata response with all the supported endpoints using HTTPS URLs.

This should be used with MockClientBuilder::insecure_rewrite_https_to_http() to bypass checks from the oauth2 crate.

Source

pub fn ok_without_device_authorization(self) -> MatrixMock<'a>

Returns a successful metadata response without the device authorization endpoint.

Source

pub fn ok_without_registration(self) -> MatrixMock<'a>

Returns a successful metadata response without the registration endpoint.

Source§

impl<'a> MockEndpoint<'a, RegistrationEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful registration response.

Source§

impl<'a> MockEndpoint<'a, DeviceAuthorizationEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful device authorization response.

Source§

impl<'a> MockEndpoint<'a, TokenEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful token response with the default tokens.

Source

pub fn ok_with_tokens( self, access_token: &str, refresh_token: &str, ) -> MatrixMock<'a>

Returns a successful token response with custom tokens.

Source

pub fn access_denied(self) -> MatrixMock<'a>

Returns an error response when the request was invalid.

Source

pub fn expired_token(self) -> MatrixMock<'a>

Returns an error response when the token in the request has expired.

Source

pub fn invalid_grant(self) -> MatrixMock<'a>

Returns an error response when the token in the request is invalid.

Source§

impl<'a> MockEndpoint<'a, RevocationEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful revocation response.

Source§

impl<'a, T> MockEndpoint<'a, T>

Source

pub fn expect_default_access_token(self) -> Self

Expect authentication with the default access token on this endpoint.

Source

pub fn expect_access_token(self, access_token: &'static str) -> Self

Expect authentication with the given access token on this endpoint.

Source

pub fn do_not_expect_access_token(self) -> Self

Don’t expect authentication with an access token on this endpoint.

This should be used to override the default behavior of the endpoint, when the access token is unknown for example.

Source

pub fn respond_with<R: Respond + 'static>(self, func: R) -> MatrixMock<'a>

Specify how to respond to a query (viz., like MockBuilder::respond_with does), when other predefined responses aren’t sufficient.

§Examples
use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;
use wiremock::ResponseTemplate;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
mock_server
    .mock_room_send()
    .respond_with(
        ResponseTemplate::new(429)
            .insert_header("Retry-After", "100")
            .set_body_json(json!({
                "errcode": "M_LIMIT_EXCEEDED",
                "custom_field": "with custom data",
    })))
    .expect(1)
    .mount()
    .await;

room
    .send_raw("m.room.message", json!({ "body": "Hello world" }))
    .await
    .expect_err("The sending of the event should fail");
Source

pub fn error500(self) -> MatrixMock<'a>

Returns a send endpoint that emulates a transient failure, i.e responds with error 500.

§Examples
use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

mock_server
    .mock_room_send()
    .error500()
    .expect(1)
    .mount()
    .await;

room
    .send_raw("m.room.message", json!({ "body": "Hello world" }))
    .await.expect_err("The sending of the event should have failed");
Source

pub fn error_too_large(self) -> MatrixMock<'a>

Returns an endpoint that emulates a permanent failure error (e.g. event is too large).

§Examples
use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

mock_server
    .mock_room_send()
    .error_too_large()
    .expect(1)
    .mount()
    .await;

room
    .send_raw("m.room.message", json!({ "body": "Hello world" }))
    .await.expect_err("The sending of the event should have failed");
Source§

impl<'a> MockEndpoint<'a, RoomSendEndpoint>

Source

pub fn body_matches_partial_json(self, body: Value) -> Self

Ensures that the body of the request is a superset of the provided body parameter.

§Examples
use matrix_sdk::{
    ruma::{room_id, event_id, events::room::message::RoomMessageEventContent},
    test_utils::mocks::MatrixMockServer
};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
mock_server
    .mock_room_send()
    .body_matches_partial_json(json!({
        "body": "Hello world",
    }))
    .ok(event_id)
    .expect(1)
    .mount()
    .await;

let content = RoomMessageEventContent::text_plain("Hello world");
let response = room.send(content).await?;

assert_eq!(
    event_id,
    response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn for_type(self, event_type: MessageLikeEventType) -> Self

Ensures that the send endpoint request uses a specific event type.

§Examples

see also MatrixMockServer::mock_room_send for more context.

use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
mock_server
    .mock_room_send()
    .for_type("m.room.message".into())
    .ok(event_id)
    .expect(1)
    .mount()
    .await;

let response_not_mocked = room.send_raw("m.room.reaction", json!({ "body": "Hello world" })).await;
// The `m.room.reaction` event type should not be mocked by the server.
assert!(response_not_mocked.is_err());

let response = room.send_raw("m.room.message", json!({ "body": "Hello world" })).await?;
// The `m.room.message` event type should be mocked by the server.
assert_eq!(
    event_id,
    response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn match_delayed_event(self, delay: Duration) -> Self

Ensures the event was sent as a delayed event.

See also the MSC.

Note: works with any room.

§Examples

see also MatrixMockServer::mock_room_send for more context.

use matrix_sdk::{
    ruma::{
        api::client::delayed_events::{delayed_message_event, DelayParameters},
        events::{message::MessageEventContent, AnyMessageLikeEventContent},
        room_id,
        time::Duration,
        TransactionId,
    },
    test_utils::mocks::MatrixMockServer,
};
use serde_json::json;
use wiremock::ResponseTemplate;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server.sync_joined_room(&client, room_id!("!room_id:localhost")).await;

mock_server
    .mock_room_send()
    .match_delayed_event(Duration::from_millis(500))
    .respond_with(ResponseTemplate::new(200).set_body_json(json!({"delay_id":"$some_id"})))
    .mock_once()
    .mount()
    .await;

let response_not_mocked =
    room.send_raw("m.room.message", json!({ "body": "Hello world" })).await;

// A non delayed event should not be mocked by the server.
assert!(response_not_mocked.is_err());

let r = delayed_message_event::unstable::Request::new(
    room.room_id().to_owned(),
    TransactionId::new(),
    DelayParameters::Timeout { timeout: Duration::from_millis(500) },
    &AnyMessageLikeEventContent::Message(MessageEventContent::plain("hello world")),
)
.unwrap();

let response = room.client().send(r).await.unwrap();
// The delayed `m.room.message` event type should be mocked by the server.
assert_eq!("$some_id", response.delay_id);
Source

pub fn ok(self, returned_event_id: impl Into<OwnedEventId>) -> MatrixMock<'a>

Returns a send endpoint that emulates success, i.e. the event has been sent with the given event id.

§Examples
use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
let send_guard = mock_server
    .mock_room_send()
    .ok(event_id)
    .expect(1)
    .mount_as_scoped()
    .await;

let response = room.send_raw("m.room.message", json!({ "body": "Hello world" })).await?;

assert_eq!(
    event_id,
    response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn ok_with_capture( self, returned_event_id: impl Into<OwnedEventId>, event_sender: impl Into<OwnedUserId>, ) -> (Receiver<Raw<AnySyncTimelineEvent>>, MatrixMock<'a>)

Returns a send endpoint that emulates success, i.e. the event has been sent with the given event id.

The sent event is captured and can be accessed using the returned Receiver. The Receiver is valid only for a send call. The given event_sender are added to the event JSON.

§Examples
use matrix_sdk::{
    ruma::{
        event_id, events::room::message::RoomMessageEventContent, room_id,
    },
    test_utils::mocks::MatrixMockServer,
};
use matrix_sdk_test::JoinedRoomBuilder;

let room_id = room_id!("!room_id:localhost");
let event_id = event_id!("$some_id");

let server = MatrixMockServer::new().await;
let client = server.client_builder().build().await;

let user_id = client.user_id().expect("We should have a user ID by now");

let (receiver, mock) =
    server.mock_room_send().ok_with_capture(event_id, user_id);

server
    .mock_sync()
    .ok_and_run(&client, |builder| {
        builder.add_joined_room(JoinedRoomBuilder::new(room_id));
    })
    .await;

// Mock any additional endpoints that might be needed to send the message.

let room = client
    .get_room(room_id)
    .expect("We should have access to our room now");

let event_id = room
    .send(RoomMessageEventContent::text_plain("It's a secret to everybody"))
    .await
    .expect("We should be able to send an initial message")
    .event_id;

let event = receiver.await?;
Source§

impl<'a> MockEndpoint<'a, RoomSendStateEndpoint>

Source

pub fn body_matches_partial_json(self, body: Value) -> Self

Ensures that the body of the request is a superset of the provided body parameter.

§Examples
use matrix_sdk::{
    ruma::{
        room_id, event_id,
        events::room::power_levels::RoomPowerLevelsEventContent,
        room_version_rules::AuthorizationRules
    },
    test_utils::mocks::MatrixMockServer
};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
mock_server
    .mock_room_send_state()
    .body_matches_partial_json(json!({
        "redact": 51,
    }))
    .ok(event_id)
    .expect(1)
    .mount()
    .await;

let mut content = RoomPowerLevelsEventContent::new(&AuthorizationRules::V1);
// Update the power level to a non default value.
// Otherwise it will be skipped from serialization.
content.redact = 51.into();

let response = room.send_state_event(content).await?;

assert_eq!(
    event_id,
    response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn for_type(self, event_type: StateEventType) -> Self

Ensures that the send endpoint request uses a specific event type.

Note: works with any room.

§Examples

see also MatrixMockServer::mock_room_send for more context.

use matrix_sdk::{
    ruma::{
        event_id,
        events::room::{
            create::RoomCreateEventContent, power_levels::RoomPowerLevelsEventContent,
        },
        events::StateEventType,
        room_id,
        room_version_rules::AuthorizationRules,
    },
    test_utils::mocks::MatrixMockServer,
};

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server.sync_joined_room(&client, room_id!("!room_id:localhost")).await;

let event_id = event_id!("$some_id");

mock_server
    .mock_room_send_state()
    .for_type(StateEventType::RoomPowerLevels)
    .ok(event_id)
    .expect(1)
    .mount()
    .await;

let response_not_mocked = room.send_state_event(RoomCreateEventContent::new_v11()).await;
// The `m.room.reaction` event type should not be mocked by the server.
assert!(response_not_mocked.is_err());

let response = room.send_state_event(RoomPowerLevelsEventContent::new(&AuthorizationRules::V1)).await?;
// The `m.room.message` event type should be mocked by the server.
assert_eq!(
    event_id, response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn match_delayed_event(self, delay: Duration) -> Self

Ensures the event was sent as a delayed event.

See also the MSC.

Note: works with any room.

§Examples

see also MatrixMockServer::mock_room_send for more context.

use matrix_sdk::{
    ruma::{
        api::client::delayed_events::{delayed_state_event, DelayParameters},
        events::{room::create::RoomCreateEventContent, AnyStateEventContent},
        room_id,
        time::Duration,
    },
    test_utils::mocks::MatrixMockServer,
};
use wiremock::ResponseTemplate;
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server.sync_joined_room(&client, room_id!("!room_id:localhost")).await;

mock_server
    .mock_room_send_state()
    .match_delayed_event(Duration::from_millis(500))
    .respond_with(ResponseTemplate::new(200).set_body_json(json!({"delay_id":"$some_id"})))
    .mock_once()
    .mount()
    .await;

let response_not_mocked = room.send_state_event(RoomCreateEventContent::new_v11()).await;
// A non delayed event should not be mocked by the server.
assert!(response_not_mocked.is_err());

let r = delayed_state_event::unstable::Request::new(
    room.room_id().to_owned(),
    "".to_owned(),
    DelayParameters::Timeout { timeout: Duration::from_millis(500) },
    &AnyStateEventContent::RoomCreate(RoomCreateEventContent::new_v11()),
)
.unwrap();
let response = room.client().send(r).await.unwrap();
// The delayed `m.room.message` event type should be mocked by the server.
assert_eq!("$some_id", response.delay_id);
Source

pub fn for_key(self, state_key: String) -> Self

use matrix_sdk::{
    ruma::{
        event_id,
        events::{call::member::CallMemberEventContent, AnyStateEventContent},
        room_id,
    },
    test_utils::mocks::MatrixMockServer,
};

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server.sync_joined_room(&client, room_id!("!room_id:localhost")).await;

let event_id = event_id!("$some_id");

mock_server
    .mock_room_send_state()
    .for_key("my_key".to_owned())
    .ok(event_id)
    .expect(1)
    .mount()
    .await;

let response_not_mocked = room
    .send_state_event_for_key(
        "",
        AnyStateEventContent::CallMember(CallMemberEventContent::new_empty(None)),
    )
    .await;
// The `m.room.reaction` event type should not be mocked by the server.
assert!(response_not_mocked.is_err());

let response = room
    .send_state_event_for_key(
        "my_key",
        AnyStateEventContent::CallMember(CallMemberEventContent::new_empty(None)),
    )
    .await
    .unwrap();

// The `m.room.message` event type should be mocked by the server.
assert_eq!(
    event_id, response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source

pub fn ok(self, returned_event_id: impl Into<OwnedEventId>) -> MatrixMock<'a>

Returns a send endpoint that emulates success, i.e. the event has been sent with the given event id.

§Examples
use matrix_sdk::{ruma::{room_id, event_id}, test_utils::mocks::MatrixMockServer};
use serde_json::json;

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

let event_id = event_id!("$some_id");
let send_guard = mock_server
    .mock_room_send_state()
    .ok(event_id)
    .expect(1)
    .mount_as_scoped()
    .await;

let response = room.send_state_event_raw("m.room.message", "my_key", json!({ "body": "Hello world" })).await?;

assert_eq!(
    event_id,
    response.event_id,
    "The event ID we mocked should match the one we received when we sent the event"
);
Source§

impl<'a> MockEndpoint<'a, SyncEndpoint>

Source

pub fn timeout(self, timeout: Option<Duration>) -> Self

Expect the given timeout, or lack thereof, in the request.

Source

pub fn ok<F: FnOnce(&mut SyncResponseBuilder)>(self, func: F) -> MatrixMock<'a>

Mocks the sync endpoint, using the given function to generate the response.

Source

pub async fn ok_and_run<F: FnOnce(&mut SyncResponseBuilder)>( self, client: &Client, func: F, )

Temporarily mocks the sync with the given endpoint and runs a client sync with it.

After calling this function, the sync endpoint isn’t mocked anymore.

§Examples
use matrix_sdk::{ruma::room_id, test_utils::mocks::MatrixMockServer};
use matrix_sdk_test::JoinedRoomBuilder;

// First create the mock server and client pair.
let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;
let room_id = room_id!("!room_id:localhost");

// Let's emulate what `MatrixMockServer::sync_joined_room()` does.
mock_server
    .mock_sync()
    .ok_and_run(&client, |builder| {
        builder.add_joined_room(JoinedRoomBuilder::new(room_id));
    })
    .await;

let room = client
    .get_room(room_id)
    .expect("The room should be available after we mocked the sync");
Source§

impl<'a> MockEndpoint<'a, EncryptionStateEndpoint>

Source

pub fn encrypted(self) -> MatrixMock<'a>

Marks the room as encrypted.

§Examples
use matrix_sdk::{ruma::room_id, test_utils::mocks::MatrixMockServer};

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().encrypted().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

assert!(
    room.latest_encryption_state().await?.is_encrypted(),
    "The room should be marked as encrypted."
);
Source

pub fn plain(self) -> MatrixMock<'a>

Marks the room as not encrypted.

§Examples
use matrix_sdk::{ruma::room_id, test_utils::mocks::MatrixMockServer};

let mock_server = MatrixMockServer::new().await;
let client = mock_server.client_builder().build().await;

mock_server.mock_room_state_encryption().plain().mount().await;

let room = mock_server
    .sync_joined_room(&client, room_id!("!room_id:localhost"))
    .await;

assert!(
    !room.latest_encryption_state().await?.is_encrypted(),
    "The room should not be marked as encrypted."
);
Source§

impl<'a> MockEndpoint<'a, SetEncryptionStateEndpoint>

Source

pub fn ok(self, returned_event_id: impl Into<OwnedEventId>) -> MatrixMock<'a>

Returns a mock for a successful setting of the encryption state event.

Source§

impl<'a> MockEndpoint<'a, RoomRedactEndpoint>

Source

pub fn ok(self, returned_event_id: impl Into<OwnedEventId>) -> MatrixMock<'a>

Returns a redact endpoint that emulates success, i.e. the redaction event has been sent with the given event id.

Source§

impl<'a> MockEndpoint<'a, RoomEventEndpoint>

Source

pub fn room(self, room: impl Into<OwnedRoomId>) -> Self

Limits the scope of this mock to a specific room.

Source

pub fn match_event_id(self) -> Self

Whether the mock checks for the event id from the event.

Source

pub fn ok(self, event: TimelineEvent) -> MatrixMock<'a>

Returns a redact endpoint that emulates success, i.e. the redaction event has been sent with the given event id.

Source§

impl<'a> MockEndpoint<'a, RoomEventContextEndpoint>

Source

pub fn room(self, room: impl Into<OwnedRoomId>) -> Self

Limits the scope of this mock to a specific room.

Source

pub fn match_event_id(self) -> Self

Whether the mock checks for the event id from the event.

Source

pub fn ok( self, event: TimelineEvent, start: impl Into<String>, end: impl Into<String>, state_events: Vec<Raw<AnyStateEvent>>, ) -> MatrixMock<'a>

Returns an endpoint that emulates success.

Source§

impl<'a> MockEndpoint<'a, RoomMessagesEndpoint>

A prebuilt mock for getting a room messages in a room.

Source

pub fn match_limit(self, limit: u32) -> Self

Expects an optional limit to be set on the request.

Source

pub fn match_from(self, from: &str) -> Self

Expects an optional from to be set on the request.

Source

pub fn ok(self, response: RoomMessagesResponseTemplate) -> MatrixMock<'a>

Returns a messages endpoint that emulates success, i.e. the messages provided as response could be retrieved.

Note: pass chunk in the correct order: topological for forward pagination, reverse topological for backwards pagination.

Source§

impl<'a> MockEndpoint<'a, UploadEndpoint>

Source

pub fn expect_mime_type(self, content_type: &str) -> Self

Expect that the content type matches what’s given here.

Source

pub fn ok_with_capture( self, mxc_id: &MxcUri, ) -> (Receiver<Vec<u8>>, MatrixMock<'a>)

Returns a upload endpoint that emulates success, i.e. the media has been uploaded to the media server and can be accessed using the given event has been sent with the given MxcUri.

The uploaded content is captured and can be accessed using the returned Receiver. The Receiver is valid only for a single media upload.

§Examples
use matrix_sdk::{
    ruma::{event_id, mxc_uri, room_id},
    test_utils::mocks::MatrixMockServer,
};

let mxid = mxc_uri!("mxc://localhost/12345");

let server = MatrixMockServer::new().await;
let (receiver, upload_mock) = server.mock_upload().ok_with_capture(mxid);
let client = server.client_builder().build().await;

client.media().upload(&mime::TEXT_PLAIN, vec![1, 2, 3, 4, 5], None).await?;

let uploaded = receiver.await?;

assert_eq!(uploaded, vec![1, 2, 3, 4, 5]);
Source

pub fn ok(self, mxc_id: &MxcUri) -> MatrixMock<'a>

Returns a upload endpoint that emulates success, i.e. the media has been uploaded to the media server and can be accessed using the given event has been sent with the given MxcUri.

Source§

impl<'a> MockEndpoint<'a, ResolveRoomAliasEndpoint>

Source

pub fn for_alias(self, alias: impl Into<String>) -> Self

Sets up the endpoint to only intercept requests for the given room alias.

Source

pub fn ok(self, room_id: &str, servers: Vec<String>) -> MatrixMock<'a>

Returns a data endpoint with a resolved room alias.

Source

pub fn not_found(self) -> MatrixMock<'a>

Returns a data endpoint for a room alias that does not exit.

Source§

impl<'a> MockEndpoint<'a, CreateRoomAliasEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a data endpoint for creating a room alias.

Source§

impl<'a> MockEndpoint<'a, RemoveRoomAliasEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a data endpoint for removing a room alias.

Source§

impl<'a> MockEndpoint<'a, PublicRoomsEndpoint>

Source

pub fn ok( self, chunk: Vec<PublicRoomsChunk>, next_batch: Option<String>, prev_batch: Option<String>, total_room_count_estimate: Option<u64>, ) -> MatrixMock<'a>

Returns a data endpoint for paginating the public room list.

Source

pub fn ok_with_via_params( self, server_map: BTreeMap<OwnedServerName, Vec<PublicRoomsChunk>>, ) -> MatrixMock<'a>

Returns a data endpoint for paginating the public room list with several via params.

Each via param must be in the server_map parameter, otherwise it’ll fail.

Source§

impl<'a> MockEndpoint<'a, GetRoomVisibilityEndpoint>

Source

pub fn ok(self, visibility: Visibility) -> MatrixMock<'a>

Returns an endpoint that get the room’s public visibility.

Source§

impl<'a> MockEndpoint<'a, SetRoomVisibilityEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns an endpoint that updates the room’s visibility.

Source§

impl<'a> MockEndpoint<'a, RoomKeysVersionEndpoint>

Source

pub fn exists(self) -> MatrixMock<'a>

Returns an endpoint that says there is a single room keys backup

Source

pub fn none(self) -> MatrixMock<'a>

Returns an endpoint that says there is no room keys backup

Source

pub fn error429(self) -> MatrixMock<'a>

Returns an endpoint that 429 errors when we get it

Source

pub fn error404(self) -> MatrixMock<'a>

Returns an endpoint that 404 errors when we get it

Source§

impl<'a> MockEndpoint<'a, AddRoomKeysVersionEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns an endpoint that may be used to add room key backups

Source§

impl<'a> MockEndpoint<'a, DeleteRoomKeysVersionEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns an endpoint that allows deleting room key backups

Source§

impl<'a> MockEndpoint<'a, SendToDeviceEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with default data.

Source§

impl<'a> MockEndpoint<'a, GetRoomMembersEndpoint>

Source

pub fn ok(self, members: Vec<Raw<RoomMemberEvent>>) -> MatrixMock<'a>

Returns a successful get members request with a list of members.

Source§

impl<'a> MockEndpoint<'a, InviteUserByIdEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful invite user by id request.

Source§

impl<'a> MockEndpoint<'a, KickUserEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful kick user request.

Source§

impl<'a> MockEndpoint<'a, BanUserEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful ban user request.

Source§

impl<'a> MockEndpoint<'a, VersionsEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful /_matrix/client/versions request.

The response will return some commonly supported versions.

Source

pub fn ok_with_unstable_features(self) -> MatrixMock<'a>

Returns a successful /_matrix/client/versions request.

The response will return some commonly supported versions and unstable features supported by the SDK.

Source

pub fn ok_custom( self, versions: &[&str], unstable_features: &BTreeMap<&str, bool>, ) -> MatrixMock<'a>

Returns a successful /_matrix/client/versions request with the given versions and unstable features.

Source§

impl<'a> MockEndpoint<'a, RoomSummaryEndpoint>

Source

pub fn ok(self, room_id: &RoomId) -> MatrixMock<'a>

Returns a successful response with some default data for the given room id.

Source§

impl<'a> MockEndpoint<'a, SetRoomPinnedEventsEndpoint>

Source

pub fn ok(self, event_id: OwnedEventId) -> MatrixMock<'a>

Returns a successful response with a given event id. id.

Source

pub fn unauthorized(self) -> MatrixMock<'a>

Returns an error response with a generic error code indicating the client is not authorized to set pinned events.

Source§

impl<'a> MockEndpoint<'a, WhoAmIEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with the default device ID.

Source

pub fn ok_with_device_id(self, device_id: &DeviceId) -> MatrixMock<'a>

Returns a successful response with the given device ID.

Source

pub fn err_unknown_token(self) -> MatrixMock<'a>

Returns an error response with an M_UNKNOWN_TOKEN.

Source§

impl<'a> MockEndpoint<'a, UploadKeysEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with counts of 10 curve25519 keys and 20 signed curve25519 keys.

Source§

impl<'a> MockEndpoint<'a, QueryKeysEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source§

impl<'a> MockEndpoint<'a, WellKnownEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with the URL for this homeserver.

Source

pub fn ok_with_homeserver_url(self, homeserver_url: &str) -> MatrixMock<'a>

Returns a successful response with the given homeserver URL.

Source

pub fn error404(self) -> MatrixMock<'a>

Returns a 404 error response.

Source§

impl<'a> MockEndpoint<'a, UploadCrossSigningKeysEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source

pub fn uiaa_invalid_password(self) -> MatrixMock<'a>

Returns an error response with a UIAA stage that failed to authenticate because of an invalid password.

Source

pub fn uiaa(self) -> MatrixMock<'a>

Returns an error response with a UIAA stage.

Source

pub fn uiaa_oauth(self) -> MatrixMock<'a>

Returns an error response with an OAuth 2.0 UIAA stage.

Source§

impl<'a> MockEndpoint<'a, UploadCrossSigningSignaturesEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source§

impl<'a> MockEndpoint<'a, RoomLeaveEndpoint>

Source

pub fn ok(self, room_id: &RoomId) -> MatrixMock<'a>

Returns a successful response with some default data for the given room id.

Source

pub fn forbidden(self) -> MatrixMock<'a>

Returns a M_FORBIDDEN response.

Source§

impl<'a> MockEndpoint<'a, RoomForgetEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with some default data for the given room id.

Source§

impl<'a> MockEndpoint<'a, LogoutEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source§

impl<'a> MockEndpoint<'a, RoomThreadsEndpoint>

Source

pub fn match_from(self, from: &str) -> Self

Expects an optional from to be set on the request.

Source

pub fn ok( self, chunk: Vec<Raw<AnyTimelineEvent>>, next_batch: Option<String>, ) -> MatrixMock<'a>

Returns a successful response with some optional events and previous batch token.

Source§

impl<'a> MockEndpoint<'a, RoomRelationsEndpoint>

Source

pub fn match_from(self, from: &str) -> Self

Expects an optional from to be set on the request.

Source

pub fn match_limit(self, limit: u32) -> Self

Expects an optional limit to be set on the request.

Source

pub fn match_subrequest(self, spec: IncludeRelations) -> Self

Match the given subrequest, according to the given specification.

Source

pub fn match_target_event(self, event_id: OwnedEventId) -> Self

Expects the request to match a specific event id.

Source

pub fn ok(self, response: RoomRelationsResponseTemplate) -> MatrixMock<'a>

Returns a successful response with some optional events and pagination tokens.

Source§

impl<'a> MockEndpoint<'a, GlobalAccountDataEndpoint>

Source

pub fn ok( self, user_id: &UserId, event_type: GlobalAccountDataEventType, json_response: Value, ) -> MatrixMock<'a>

Returns a mock for a successful global account data event.

Source

pub fn not_found( self, user_id: &UserId, event_type: GlobalAccountDataEventType, ) -> MatrixMock<'a>

Returns a mock for a not found global account data event.

Source§

impl<'a> MockEndpoint<'a, ReceiptEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source

pub fn body_matches_partial_json(self, body: Value) -> Self

Ensures that the body of the request is a superset of the provided body parameter.

Source

pub fn body_json(self, body: Value) -> Self

Ensures that the body of the request is the exact provided body parameter.

Source

pub fn match_thread(self, thread: ReceiptThread) -> Self

Ensures that the request matches a specific receipt thread.

Source

pub fn match_event_id(self, event_id: &EventId) -> Self

Ensures that the request matches a specific event id.

Source§

impl<'a> MockEndpoint<'a, ReadMarkersEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source§

impl<'a> MockEndpoint<'a, RoomAccountDataEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty response.

Source§

impl<'a> MockEndpoint<'a, AuthenticatedMediaConfigEndpoint>

Source

pub fn ok(self, max_upload_size: UInt) -> MatrixMock<'a>

Returns a successful response with the provided max upload size.

Source

pub fn ok_default(self) -> MatrixMock<'a>

Returns a successful response with a maxed out max upload size.

Source§

impl<'a> MockEndpoint<'a, MediaConfigEndpoint>

Source

pub fn ok(self, max_upload_size: UInt) -> MatrixMock<'a>

Returns a successful response with the provided max upload size.

Source§

impl<'a> MockEndpoint<'a, LoginEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source

pub fn ok_with(self, response: LoginResponseTemplate200) -> MatrixMock<'a>

Returns a given response on POST /login requests

§Arguments
  • response - The response that the mock server sends on POST /login requests.
§Returns

Returns a MatrixMock which can be mounted.

§Examples
use matrix_sdk::test_utils::mocks::{
    LoginResponseTemplate200, MatrixMockServer,
};
use matrix_sdk_test::async_test;
use ruma::{device_id, time::Duration, user_id};

#[async_test]
async fn test_ok_with() {
    let server = MatrixMockServer::new().await;
    server
        .mock_login()
        .ok_with(LoginResponseTemplate200::new(
            "qwerty",
            device_id!("DEADBEEF"),
            user_id!("@cheeky_monkey:matrix.org"),
        ))
        .mount()
        .await;

    let client = server.client_builder().unlogged().build().await;

    let result = client
        .matrix_auth()
        .login_username("example", "wordpass")
        .send()
        .await
        .unwrap();

    assert!(
        result.access_tokesn.unwrap() == "qwerty",
        "wrong access token in response"
    );
    assert!(
        result.device_id.unwrap() == "DEADBEEF",
        "wrong device id in response"
    );
    assert!(
        result.user_id.unwrap() == "@cheeky_monkey:matrix.org",
        "wrong user id in response"
    );
}
Source

pub fn body_matches_partial_json(self, body: Value) -> Self

Ensures that the body of the request is a superset of the provided body parameter.

Source§

impl<'a> MockEndpoint<'a, DevicesEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source§

impl<'a> MockEndpoint<'a, UserDirectoryEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source§

impl<'a> MockEndpoint<'a, CreateRoomEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source§

impl<'a> MockEndpoint<'a, UpgradeRoomEndpoint>

Source

pub fn ok_with(self, new_room_id: &RoomId) -> MatrixMock<'a>

Returns a successful response with desired replacement_room ID.

Source§

impl<'a> MockEndpoint<'a, MediaAllocateEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source§

impl<'a> MockEndpoint<'a, MediaAllocatedUploadEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response.

Source§

impl<'a> MockEndpoint<'a, MediaDownloadEndpoint>

Source

pub fn ok_plain_text(self) -> MatrixMock<'a>

Returns a successful response with a plain text content.

Source

pub fn ok_image(self) -> MatrixMock<'a>

Returns a successful response with a fake image content.

Source§

impl<'a> MockEndpoint<'a, MediaThumbnailEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with a fake image content.

Source§

impl<'a> MockEndpoint<'a, AuthedMediaDownloadEndpoint>

Source

pub fn ok_plain_text(self) -> MatrixMock<'a>

Returns a successful response with a plain text content.

Source

pub fn ok_bytes(self, bytes: Vec<u8>) -> MatrixMock<'a>

Returns a successful response with the given bytes.

Source

pub fn ok_image(self) -> MatrixMock<'a>

Returns a successful response with a fake image content.

Source§

impl<'a> MockEndpoint<'a, AuthedMediaThumbnailEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with a fake image content.

Source§

impl<'a> MockEndpoint<'a, JoinRoomEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response using the provided RoomId.

Source§

impl<'a> MockEndpoint<'a, RoomGetThreadSubscriptionEndpoint>

Source

pub fn ok(self, automatic: bool) -> MatrixMock<'a>

Returns a successful response for the given thread subscription.

Source

pub fn match_room_id(self, room_id: OwnedRoomId) -> Self

Match the request parameter against a specific room id.

Source

pub fn match_thread_id(self, thread_root: OwnedEventId) -> Self

Match the request parameter against a specific thread root event id.

Source§

impl<'a> MockEndpoint<'a, RoomPutThreadSubscriptionEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response for the given setting of thread subscription.

Source

pub fn conflicting_unsubscription(self) -> MatrixMock<'a>

Returns that the server skipped an automated thread subscription, because the user unsubscribed to the thread after the event id passed in the automatic subscription.

Source

pub fn match_room_id(self, room_id: OwnedRoomId) -> Self

Match the request parameter against a specific room id.

Source

pub fn match_thread_id(self, thread_root: OwnedEventId) -> Self

Match the request parameter against a specific thread root event id.

Source

pub fn match_automatic_event_id(self, up_to_event_id: &EventId) -> Self

Match the request body’s automatic field against a specific event id.

Source§

impl<'a> MockEndpoint<'a, RoomDeleteThreadSubscriptionEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response for the deletion of a given thread subscription.

Source

pub fn match_room_id(self, room_id: OwnedRoomId) -> Self

Match the request parameter against a specific room id.

Source

pub fn match_thread_id(self, thread_root: OwnedEventId) -> Self

Match the request parameter against a specific thread root event id.

Source§

impl<'a> MockEndpoint<'a, EnablePushRuleEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty JSON response.

Source§

impl<'a> MockEndpoint<'a, SetPushRulesActionsEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty JSON response.

Source§

impl<'a> MockEndpoint<'a, SetPushRulesEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty JSON response.

Source§

impl<'a> MockEndpoint<'a, DeletePushRulesEndpoint>

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful empty JSON response.

Source§

impl<'a> MockEndpoint<'a, FederationVersionEndpoint>

Source

pub fn ok(self, server_name: &str, version: &str) -> MatrixMock<'a>

Returns a successful response with the given server name and version.

Source

pub fn ok_empty(self) -> MatrixMock<'a>

Returns a successful response with empty/missing server information.

Source§

impl<'a> MockEndpoint<'a, GetThreadSubscriptionsEndpoint>

Source

pub fn add_subscription( self, room_id: OwnedRoomId, thread_root: OwnedEventId, subscription: ThreadSubscription, ) -> Self

Add a single thread subscription to the response.

Source

pub fn add_unsubcription( self, room_id: OwnedRoomId, thread_root: OwnedEventId, unsubscription: ThreadUnsubscription, ) -> Self

Add a single thread unsubscription to the response.

Source

pub fn with_delay(self, delay: Duration) -> Self

Respond with a given delay to the query.

Source

pub fn match_from(self, from: &str) -> Self

Match the from query parameter to a given value.

Source

pub fn match_to(self, to: &str) -> Self

Match the to query parameter to a given value.

Source

pub fn ok(self, end: Option<String>) -> MatrixMock<'a>

Returns a successful response with the given thread subscriptions, and “end” parameter to be used in the next query.

Source§

impl<'a> MockEndpoint<'a, GetHierarchyEndpoint>

Source

pub fn ok_with_room_ids(self, room_ids: Vec<&RoomId>) -> MatrixMock<'a>

Returns a successful response containing the given room IDs.

Source

pub fn ok_with_room_ids_and_children_state( self, room_ids: Vec<&RoomId>, children_state: Vec<&RoomId>, ) -> MatrixMock<'a>

Returns a successful response containing the given room IDs and children states

Source

pub fn ok(self) -> MatrixMock<'a>

Returns a successful response with an empty list of rooms.

Source§

impl<'a> MockEndpoint<'a, SlidingSyncEndpoint>

Source

pub fn ok(self, response: Response) -> MatrixMock<'a>

Mocks the sliding sync endpoint with the given response.

Source

pub async fn ok_and_run<F: FnOnce(SlidingSyncBuilder) -> SlidingSyncBuilder>( self, client: &Client, on_builder: F, response: Response, )

Temporarily mocks the sync with the given endpoint and runs a client sync with it.

After calling this function, the sync endpoint isn’t mocked anymore.

Auto Trait Implementations§

§

impl<'a, T> Freeze for MockEndpoint<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for MockEndpoint<'a, T>

§

impl<'a, T> Send for MockEndpoint<'a, T>
where T: Send,

§

impl<'a, T> Sync for MockEndpoint<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for MockEndpoint<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for MockEndpoint<'a, T>

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
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<>
Source§

fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> SendOutsideWasm for T
where T: Send,

Source§

impl<T> SyncOutsideWasm for T
where T: Sync,