pub struct FinamApi { /* private fields */ }Expand description
One channel plus a shared token manager. Hands out service clients that attach the JWT to each call.
Cheap to clone (the channel is reference counted). Each accessor builds a new client over the same channel, so there is no need to keep clients around.
A streaming call keeps the JWT it was opened with. Open it again after the token is renewed (the connectors do this for their own streams).
See the module docs for a complete example.
Implementations§
Source§impl FinamApi
impl FinamApi
Sourcepub fn connect(
ep: &ApiEndpoint,
tokens: Arc<TokenManager>,
bearer: bool,
) -> Result<Self, FinamError>
pub fn connect( ep: &ApiEndpoint, tokens: Arc<TokenManager>, bearer: bool, ) -> Result<Self, FinamError>
Opens a lazy channel to ep and uses tokens for authorization.
bearer selects the header format. false sends the bare JWT, which is what the official
SDKs do. true sends Bearer <jwt>, which some examples in the broker documentation show.
Which of the two the live broker accepts is not verified against the live API here.
§Errors
FinamError::Config when the endpoint URL is invalid (see connect_lazy).
§Examples
use brokapi_finam_protocol::{ApiEndpoint, FinamApi, FinamError, start_token_manager};
let api = FinamApi::connect(&endpoint, tokens.clone(), false)?;
assert!(std::sync::Arc::ptr_eq(api.tokens(), &tokens));
let bad = FinamApi::connect(&ApiEndpoint::new("not a url"), tokens, false);
assert!(matches!(bad, Err(FinamError::Config(_))));Sourcepub fn from_channel(
channel: Channel,
tokens: Arc<TokenManager>,
bearer: bool,
) -> Self
pub fn from_channel( channel: Channel, tokens: Arc<TokenManager>, bearer: bool, ) -> Self
Wraps a channel you built yourself (for example with custom TLS or a proxy).
Nothing is checked. bearer has the same meaning as in FinamApi::connect.
Sourcepub fn tokens(&self) -> &Arc<TokenManager>
pub fn tokens(&self) -> &Arc<TokenManager>
The token manager used by this client.
Use it to read the account list (TokenManager::account_ids) or to ask for a renewal.
Sourcepub fn grpc(&self) -> Grpc<Authorized>
pub fn grpc(&self) -> Grpc<Authorized>
A generic gRPC client over the same channel and token, for a call that is not made through a
generated client: the method is named by a path (/package.Service/Method) and the messages are
whatever codec you give it. With FILE_DESCRIPTOR_SET it calls any
method of the API by name.
Sourcepub fn orders(&self) -> OrdersServiceClient<Authorized>
pub fn orders(&self) -> OrdersServiceClient<Authorized>
OrdersService: place, cancel and read orders, order and trade streams.
Sourcepub fn accounts(&self) -> AccountsServiceClient<Authorized>
pub fn accounts(&self) -> AccountsServiceClient<Authorized>
AccountsService: account state, own trades, account stream.
Sourcepub fn market_data(&self) -> MarketDataServiceClient<Authorized>
pub fn market_data(&self) -> MarketDataServiceClient<Authorized>
MarketDataService: quotes, order books, trades, bars and their streams.
Sourcepub fn assets(&self) -> AssetsServiceClient<Authorized>
pub fn assets(&self) -> AssetsServiceClient<Authorized>
AssetsService: instrument directory, schedules, exchange clock.
Sourcepub fn usage_metrics(&self) -> UsageMetricsServiceClient<Authorized>
pub fn usage_metrics(&self) -> UsageMetricsServiceClient<Authorized>
UsageMetricsService: how much of the request quota is left.
Sourcepub fn auth(&self) -> AuthServiceClient<Authorized>
pub fn auth(&self) -> AuthServiceClient<Authorized>
AuthService with the current JWT attached. Auth and SubscribeJwtRenewal are driven by the
TokenManager; TokenDetails is reachable here.
Sourcepub fn reports(&self) -> ReportsServiceClient<Authorized>
pub fn reports(&self) -> ReportsServiceClient<Authorized>
ReportsService: account reports.
Sourcepub fn corporate_actions(&self) -> CorporateActionsServiceClient<Authorized>
pub fn corporate_actions(&self) -> CorporateActionsServiceClient<Authorized>
CorporateActionsService: splits, dividends and bond events.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FinamApi
impl !UnwindSafe for FinamApi
impl Freeze for FinamApi
impl Send for FinamApi
impl Sync for FinamApi
impl Unpin for FinamApi
impl UnsafeUnpin for FinamApi
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> 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>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].