pub struct HttpRequestCanister<'agent>(_);
Expand description

A canister that can serve a HTTP request.

Implementations§

source§

impl<'agent> HttpRequestCanister<'agent>

source

pub fn create(agent: &'agent Agent, canister_id: Principal) -> Self

Create an instance of a HttpRequestCanister interface pointing to the specified Canister ID.

source

pub fn from_canister(canister: Canister<'agent>) -> Self

Create a HttpRequestCanister interface from an existing canister object.

source§

impl<'agent> HttpRequestCanister<'agent>

source

pub fn http_request<'canister: 'agent>( &'canister self, method: impl AsRef<str>, url: impl AsRef<str>, headers: impl IntoIterator<Item = HeaderField<'agent>, IntoIter = impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>>, body: impl AsRef<[u8]>, certificate_version: Option<&u16> ) -> impl 'agent + SyncCall<(HttpResponse,)>

Performs a HTTP request, receiving a HTTP response.

source

pub fn http_request_custom<'canister: 'agent, H, T, C>( &'canister self, method: &str, url: &str, headers: H, body: &[u8], certificate_version: Option<&u16> ) -> impl 'agent + SyncCall<(HttpResponse<T, C>,)>where H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>, T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>, C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,

Performs a HTTP request, receiving a HTTP response. T and C are the token and callback types for the streaming_strategy.

source

pub fn http_request_update<'canister: 'agent>( &'canister self, method: impl AsRef<str>, url: impl AsRef<str>, headers: impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>, body: impl AsRef<[u8]> ) -> impl 'agent + AsyncCall<(HttpResponse,)>

Performs a HTTP request over an update call. Unlike query calls, update calls must pass consensus and therefore cannot be tampered with by a malicious node.

source

pub fn http_request_update_custom<'canister: 'agent, H, T, C>( &'canister self, method: &str, url: &str, headers: H, body: &[u8] ) -> impl 'agent + AsyncCall<(HttpResponse<T, C>,)>where H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>, T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>, C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,

Performs a HTTP request over an update call. Unlike query calls, update calls must pass consensus and therefore cannot be tampered with by a malicious node. T and C are the token and callback types for the streaming_strategy.

source

pub fn http_request_stream_callback<'canister: 'agent>( &'canister self, method: impl AsRef<str>, token: Token ) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse,)>

Retrieves the next chunk of a stream from a streaming callback, using the method from CallbackStrategy.

source

pub fn http_request_stream_callback_custom<'canister: 'agent, T>( &'canister self, method: impl AsRef<str>, token: T ) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse<T>,)>where T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,

Retrieves the next chunk of a stream from a streaming callback, using the method from CallbackStrategy. T is the token type.

Methods from Deref<Target = Canister<'agent>>§

source

pub fn canister_id_<'canister: 'agent>(&'canister self) -> &Principal

Get the canister ID of this canister.

source

pub fn update_<'canister: 'agent>( &'canister self, method_name: &str ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call.

source

pub fn query_<'canister: 'agent>( &'canister self, method_name: &str ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call.

source

pub async fn wait<'canister: 'agent>( &'canister self, request_id: RequestId ) -> Result<Vec<u8>, AgentError>

Call request_status on the RequestId in a loop and return the response as a byte vector.

source

pub fn clone_with_(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal.

Trait Implementations§

source§

impl<'agent> Clone for HttpRequestCanister<'agent>

source§

fn clone(&self) -> HttpRequestCanister<'agent>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'agent> Debug for HttpRequestCanister<'agent>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'agent> Deref for HttpRequestCanister<'agent>

§

type Target = Canister<'agent>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'agent> !RefUnwindSafe for HttpRequestCanister<'agent>

§

impl<'agent> Send for HttpRequestCanister<'agent>

§

impl<'agent> Sync for HttpRequestCanister<'agent>

§

impl<'agent> Unpin for HttpRequestCanister<'agent>

§

impl<'agent> !UnwindSafe for HttpRequestCanister<'agent>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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