Struct MockEndpoint

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

Generic mocked endpoint, with useful common helpers.

Implementations§

Source§

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

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 with_delay(self, delay: Duration) -> Self

Ensures the event was sent as a delayed event.

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()
    .with_delay(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§

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},
    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();
// 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,
    },
    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()).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 with_delay(self, delay: Duration) -> Self

Ensures the event was sent as a delayed event.

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()
    .with_delay(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 MockEndpoint<'_, SyncEndpoint>

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.is_encrypted().await?,
    "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.is_encrypted().await?,
    "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, RoomMessagesEndpoint>

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

Source

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

Expects an optional limit to be set on the request.

Source

pub fn 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(self, mxc_id: &MxcUri) -> 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, 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, 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§

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.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> 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> MaybeSendSync for T

Source§

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

Source§

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