pub struct Client { /* private fields */ }
Implementations§
Source§impl Client
impl Client
Sourcepub fn try_new(config: ClientConfig) -> Result<Self, ClientError>
pub fn try_new(config: ClientConfig) -> Result<Self, ClientError>
Creates a new HTTP client with the provided configuration.
§Arguments
config
- The client configuration containing an HTTP URL and an optional API key.
§Returns
Result<Self, ClientError>
- A result containing the initialized client or an error.
§Errors
Returns an error if the HTTP URL is invalid or has an unsupported scheme.
Sourcepub async fn connect_websocket(&self) -> Result<WsClient, ClientError>
pub async fn connect_websocket(&self) -> Result<WsClient, ClientError>
Establishes a WebSocket connection to the server.
§Returns
Result<WsClient, ClientError>
- A thread-safe WebSocket client for interacting with the server.
§Errors
Returns an error if the connection or the WebSocket handshake fails.
§Thread Safety
The returned WsClient
is thread-safe and can be cloned to share across multiple tasks.
Sourcepub async fn get_opportunities(
&self,
params: Option<GetOpportunitiesQueryParams>,
) -> Result<Vec<Opportunity>, ClientError>
pub async fn get_opportunities( &self, params: Option<GetOpportunitiesQueryParams>, ) -> Result<Vec<Opportunity>, ClientError>
Sourcepub async fn new_bid(
&self,
opportunity: OpportunitySvm,
params: NewBidParams,
) -> Result<BidCreate, ClientError>
pub async fn new_bid( &self, opportunity: OpportunitySvm, params: NewBidParams, ) -> Result<BidCreate, ClientError>
Creates a new bid for an SVM opportunity.
It receives a list of instructions and add the “submit_bid” or “swap” instruction to it based on the opportunity type. Then it creates a transaction with the instructions and partially signs it with the signers. Finally, it returns a Bid object with the created transaction. If you don’t want to use this method, you can use the svm::Svm::get_submit_bid_instruction or svm::Svm::get_swap_instruction methods to create the “submit_bid” or “swap” instruction and manually create the transaction and bid object.
§Arguments
opportunity
- The opportunity to bid on, received from the API.params
- Bid parameters, ex: amount, deadline, signers, etc..
§Returns
Result<BidCreate, ClientError>
- A bid creation object or an error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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