Struct teloxide::prelude::DependencyMap
source · [−]pub struct DependencyMap { /* private fields */ }Expand description
A DI container with multiple dependencies.
This DI container stores types by their corresponding type identifiers. It cannot prove at compile-time that a type of a requested value exists within the container, so if you do not provide necessary types but they were requested, it will panic.
Examples
use dptree::di::{DependencyMap, DependencySupplier};
let mut container = DependencyMap::new();
container.insert(5_i32);
container.insert("abc");
assert_eq!(container.get(), Arc::new(5_i32));
assert_eq!(container.get(), Arc::new("abc"));
// If a type of a value already exists within the container, it will be replaced.
let old_value = container.insert(10_i32).unwrap();
assert_eq!(old_value, Arc::new(5_i32));
assert_eq!(container.get(), Arc::new(10_i32));When a value is not found within the container, it will panic:
ⓘ
use dptree::di::{DependencyMap, DependencySupplier};
let mut container = DependencyMap::new();
container.insert(10i32);
container.insert(true);
container.insert("static str");
// thread 'main' panicked at 'alloc::string::String was requested, but not provided. Available types:
// &str
// bool
// i32
// ', /media/hirrolot/772CF8924BEBB279/Documents/Rust/dptree/src/di.rs:150:17
// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
let string: Arc<String> = container.get();Implementations
sourceimpl DependencyMap
impl DependencyMap
pub fn new() -> DependencyMap
sourcepub fn insert<T>(&mut self, item: T) -> Option<Arc<T>>where
T: 'static + Send + Sync,
pub fn insert<T>(&mut self, item: T) -> Option<Arc<T>>where
T: 'static + Send + Sync,
Inserts a value into the container.
If the container do not has this type present, None is returned.
Otherwise, the value is updated, and the old value is returned.
sourcepub fn insert_container(&mut self, container: DependencyMap)
pub fn insert_container(&mut self, container: DependencyMap)
Inserts all dependencies from another container into itself.
Trait Implementations
sourceimpl Clone for DependencyMap
impl Clone for DependencyMap
sourcefn clone(&self) -> DependencyMap
fn clone(&self) -> DependencyMap
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for DependencyMap
impl Debug for DependencyMap
sourceimpl Default for DependencyMap
impl Default for DependencyMap
sourcefn default() -> DependencyMap
fn default() -> DependencyMap
Returns the “default value” for a type. Read more
sourceimpl<V> DependencySupplier<V> for DependencyMapwhere
V: 'static + Send + Sync,
impl<V> DependencySupplier<V> for DependencyMapwhere
V: 'static + Send + Sync,
sourcefn get(&self) -> Arc<V>ⓘNotable traits for Arc<B>impl<B> Requester for Arc<B>where
B: Requester, type Err = <B as Requester>::Err; type GetMe = <B as Requester>::GetMe; type LogOut = <B as Requester>::LogOut; type Close = <B as Requester>::Close; type GetUpdates = <B as Requester>::GetUpdates; type SetWebhook = <B as Requester>::SetWebhook; type DeleteWebhook = <B as Requester>::DeleteWebhook; type GetWebhookInfo = <B as Requester>::GetWebhookInfo; type ForwardMessage = <B as Requester>::ForwardMessage; type CopyMessage = <B as Requester>::CopyMessage; type SendMessage = <B as Requester>::SendMessage; type SendPhoto = <B as Requester>::SendPhoto; type SendAudio = <B as Requester>::SendAudio; type SendDocument = <B as Requester>::SendDocument; type SendVideo = <B as Requester>::SendVideo; type SendAnimation = <B as Requester>::SendAnimation; type SendVoice = <B as Requester>::SendVoice; type SendVideoNote = <B as Requester>::SendVideoNote; type SendMediaGroup = <B as Requester>::SendMediaGroup; type SendLocation = <B as Requester>::SendLocation; type EditMessageLiveLocation = <B as Requester>::EditMessageLiveLocation; type EditMessageLiveLocationInline = <B as Requester>::EditMessageLiveLocationInline; type StopMessageLiveLocation = <B as Requester>::StopMessageLiveLocation; type StopMessageLiveLocationInline = <B as Requester>::StopMessageLiveLocationInline; type SendVenue = <B as Requester>::SendVenue; type SendContact = <B as Requester>::SendContact; type SendPoll = <B as Requester>::SendPoll; type SendDice = <B as Requester>::SendDice; type SendChatAction = <B as Requester>::SendChatAction; type GetUserProfilePhotos = <B as Requester>::GetUserProfilePhotos; type GetFile = <B as Requester>::GetFile; type KickChatMember = <B as Requester>::KickChatMember; type BanChatMember = <B as Requester>::BanChatMember; type UnbanChatMember = <B as Requester>::UnbanChatMember; type RestrictChatMember = <B as Requester>::RestrictChatMember; type PromoteChatMember = <B as Requester>::PromoteChatMember; type SetChatAdministratorCustomTitle = <B as Requester>::SetChatAdministratorCustomTitle; type BanChatSenderChat = <B as Requester>::BanChatSenderChat; type UnbanChatSenderChat = <B as Requester>::UnbanChatSenderChat; type SetChatPermissions = <B as Requester>::SetChatPermissions; type ExportChatInviteLink = <B as Requester>::ExportChatInviteLink; type CreateChatInviteLink = <B as Requester>::CreateChatInviteLink; type EditChatInviteLink = <B as Requester>::EditChatInviteLink; type RevokeChatInviteLink = <B as Requester>::RevokeChatInviteLink; type SetChatPhoto = <B as Requester>::SetChatPhoto; type DeleteChatPhoto = <B as Requester>::DeleteChatPhoto; type SetChatTitle = <B as Requester>::SetChatTitle; type SetChatDescription = <B as Requester>::SetChatDescription; type PinChatMessage = <B as Requester>::PinChatMessage; type UnpinChatMessage = <B as Requester>::UnpinChatMessage; type UnpinAllChatMessages = <B as Requester>::UnpinAllChatMessages; type LeaveChat = <B as Requester>::LeaveChat; type GetChat = <B as Requester>::GetChat; type GetChatAdministrators = <B as Requester>::GetChatAdministrators; type GetChatMembersCount = <B as Requester>::GetChatMembersCount; type GetChatMemberCount = <B as Requester>::GetChatMemberCount; type GetChatMember = <B as Requester>::GetChatMember; type SetChatStickerSet = <B as Requester>::SetChatStickerSet; type DeleteChatStickerSet = <B as Requester>::DeleteChatStickerSet; type AnswerCallbackQuery = <B as Requester>::AnswerCallbackQuery; type SetMyCommands = <B as Requester>::SetMyCommands; type GetMyCommands = <B as Requester>::GetMyCommands; type SetChatMenuButton = <B as Requester>::SetChatMenuButton; type GetChatMenuButton = <B as Requester>::GetChatMenuButton; type SetMyDefaultAdministratorRights = <B as Requester>::SetMyDefaultAdministratorRights; type GetMyDefaultAdministratorRights = <B as Requester>::GetMyDefaultAdministratorRights; type DeleteMyCommands = <B as Requester>::DeleteMyCommands; type AnswerInlineQuery = <B as Requester>::AnswerInlineQuery; type AnswerWebAppQuery = <B as Requester>::AnswerWebAppQuery; type EditMessageText = <B as Requester>::EditMessageText; type EditMessageTextInline = <B as Requester>::EditMessageTextInline; type EditMessageCaption = <B as Requester>::EditMessageCaption; type EditMessageCaptionInline = <B as Requester>::EditMessageCaptionInline; type EditMessageMedia = <B as Requester>::EditMessageMedia; type EditMessageMediaInline = <B as Requester>::EditMessageMediaInline; type EditMessageReplyMarkup = <B as Requester>::EditMessageReplyMarkup; type EditMessageReplyMarkupInline = <B as Requester>::EditMessageReplyMarkupInline; type StopPoll = <B as Requester>::StopPoll; type DeleteMessage = <B as Requester>::DeleteMessage; type SendSticker = <B as Requester>::SendSticker; type GetStickerSet = <B as Requester>::GetStickerSet; type GetCustomEmojiStickers = <B as Requester>::GetCustomEmojiStickers; type UploadStickerFile = <B as Requester>::UploadStickerFile; type CreateNewStickerSet = <B as Requester>::CreateNewStickerSet; type AddStickerToSet = <B as Requester>::AddStickerToSet; type SetStickerPositionInSet = <B as Requester>::SetStickerPositionInSet; type DeleteStickerFromSet = <B as Requester>::DeleteStickerFromSet; type SetStickerSetThumb = <B as Requester>::SetStickerSetThumb; type SendInvoice = <B as Requester>::SendInvoice; type CreateInvoiceLink = <B as Requester>::CreateInvoiceLink; type AnswerShippingQuery = <B as Requester>::AnswerShippingQuery; type AnswerPreCheckoutQuery = <B as Requester>::AnswerPreCheckoutQuery; type SetPassportDataErrors = <B as Requester>::SetPassportDataErrors; type SendGame = <B as Requester>::SendGame; type SetGameScore = <B as Requester>::SetGameScore; type SetGameScoreInline = <B as Requester>::SetGameScoreInline; type GetGameHighScores = <B as Requester>::GetGameHighScores; type ApproveChatJoinRequest = <B as Requester>::ApproveChatJoinRequest; type DeclineChatJoinRequest = <B as Requester>::DeclineChatJoinRequest;
fn get(&self) -> Arc<V>ⓘNotable traits for Arc<B>impl<B> Requester for Arc<B>where
B: Requester, type Err = <B as Requester>::Err; type GetMe = <B as Requester>::GetMe; type LogOut = <B as Requester>::LogOut; type Close = <B as Requester>::Close; type GetUpdates = <B as Requester>::GetUpdates; type SetWebhook = <B as Requester>::SetWebhook; type DeleteWebhook = <B as Requester>::DeleteWebhook; type GetWebhookInfo = <B as Requester>::GetWebhookInfo; type ForwardMessage = <B as Requester>::ForwardMessage; type CopyMessage = <B as Requester>::CopyMessage; type SendMessage = <B as Requester>::SendMessage; type SendPhoto = <B as Requester>::SendPhoto; type SendAudio = <B as Requester>::SendAudio; type SendDocument = <B as Requester>::SendDocument; type SendVideo = <B as Requester>::SendVideo; type SendAnimation = <B as Requester>::SendAnimation; type SendVoice = <B as Requester>::SendVoice; type SendVideoNote = <B as Requester>::SendVideoNote; type SendMediaGroup = <B as Requester>::SendMediaGroup; type SendLocation = <B as Requester>::SendLocation; type EditMessageLiveLocation = <B as Requester>::EditMessageLiveLocation; type EditMessageLiveLocationInline = <B as Requester>::EditMessageLiveLocationInline; type StopMessageLiveLocation = <B as Requester>::StopMessageLiveLocation; type StopMessageLiveLocationInline = <B as Requester>::StopMessageLiveLocationInline; type SendVenue = <B as Requester>::SendVenue; type SendContact = <B as Requester>::SendContact; type SendPoll = <B as Requester>::SendPoll; type SendDice = <B as Requester>::SendDice; type SendChatAction = <B as Requester>::SendChatAction; type GetUserProfilePhotos = <B as Requester>::GetUserProfilePhotos; type GetFile = <B as Requester>::GetFile; type KickChatMember = <B as Requester>::KickChatMember; type BanChatMember = <B as Requester>::BanChatMember; type UnbanChatMember = <B as Requester>::UnbanChatMember; type RestrictChatMember = <B as Requester>::RestrictChatMember; type PromoteChatMember = <B as Requester>::PromoteChatMember; type SetChatAdministratorCustomTitle = <B as Requester>::SetChatAdministratorCustomTitle; type BanChatSenderChat = <B as Requester>::BanChatSenderChat; type UnbanChatSenderChat = <B as Requester>::UnbanChatSenderChat; type SetChatPermissions = <B as Requester>::SetChatPermissions; type ExportChatInviteLink = <B as Requester>::ExportChatInviteLink; type CreateChatInviteLink = <B as Requester>::CreateChatInviteLink; type EditChatInviteLink = <B as Requester>::EditChatInviteLink; type RevokeChatInviteLink = <B as Requester>::RevokeChatInviteLink; type SetChatPhoto = <B as Requester>::SetChatPhoto; type DeleteChatPhoto = <B as Requester>::DeleteChatPhoto; type SetChatTitle = <B as Requester>::SetChatTitle; type SetChatDescription = <B as Requester>::SetChatDescription; type PinChatMessage = <B as Requester>::PinChatMessage; type UnpinChatMessage = <B as Requester>::UnpinChatMessage; type UnpinAllChatMessages = <B as Requester>::UnpinAllChatMessages; type LeaveChat = <B as Requester>::LeaveChat; type GetChat = <B as Requester>::GetChat; type GetChatAdministrators = <B as Requester>::GetChatAdministrators; type GetChatMembersCount = <B as Requester>::GetChatMembersCount; type GetChatMemberCount = <B as Requester>::GetChatMemberCount; type GetChatMember = <B as Requester>::GetChatMember; type SetChatStickerSet = <B as Requester>::SetChatStickerSet; type DeleteChatStickerSet = <B as Requester>::DeleteChatStickerSet; type AnswerCallbackQuery = <B as Requester>::AnswerCallbackQuery; type SetMyCommands = <B as Requester>::SetMyCommands; type GetMyCommands = <B as Requester>::GetMyCommands; type SetChatMenuButton = <B as Requester>::SetChatMenuButton; type GetChatMenuButton = <B as Requester>::GetChatMenuButton; type SetMyDefaultAdministratorRights = <B as Requester>::SetMyDefaultAdministratorRights; type GetMyDefaultAdministratorRights = <B as Requester>::GetMyDefaultAdministratorRights; type DeleteMyCommands = <B as Requester>::DeleteMyCommands; type AnswerInlineQuery = <B as Requester>::AnswerInlineQuery; type AnswerWebAppQuery = <B as Requester>::AnswerWebAppQuery; type EditMessageText = <B as Requester>::EditMessageText; type EditMessageTextInline = <B as Requester>::EditMessageTextInline; type EditMessageCaption = <B as Requester>::EditMessageCaption; type EditMessageCaptionInline = <B as Requester>::EditMessageCaptionInline; type EditMessageMedia = <B as Requester>::EditMessageMedia; type EditMessageMediaInline = <B as Requester>::EditMessageMediaInline; type EditMessageReplyMarkup = <B as Requester>::EditMessageReplyMarkup; type EditMessageReplyMarkupInline = <B as Requester>::EditMessageReplyMarkupInline; type StopPoll = <B as Requester>::StopPoll; type DeleteMessage = <B as Requester>::DeleteMessage; type SendSticker = <B as Requester>::SendSticker; type GetStickerSet = <B as Requester>::GetStickerSet; type GetCustomEmojiStickers = <B as Requester>::GetCustomEmojiStickers; type UploadStickerFile = <B as Requester>::UploadStickerFile; type CreateNewStickerSet = <B as Requester>::CreateNewStickerSet; type AddStickerToSet = <B as Requester>::AddStickerToSet; type SetStickerPositionInSet = <B as Requester>::SetStickerPositionInSet; type DeleteStickerFromSet = <B as Requester>::DeleteStickerFromSet; type SetStickerSetThumb = <B as Requester>::SetStickerSetThumb; type SendInvoice = <B as Requester>::SendInvoice; type CreateInvoiceLink = <B as Requester>::CreateInvoiceLink; type AnswerShippingQuery = <B as Requester>::AnswerShippingQuery; type AnswerPreCheckoutQuery = <B as Requester>::AnswerPreCheckoutQuery; type SetPassportDataErrors = <B as Requester>::SetPassportDataErrors; type SendGame = <B as Requester>::SendGame; type SetGameScore = <B as Requester>::SetGameScore; type SetGameScoreInline = <B as Requester>::SetGameScoreInline; type GetGameHighScores = <B as Requester>::GetGameHighScores; type ApproveChatJoinRequest = <B as Requester>::ApproveChatJoinRequest; type DeclineChatJoinRequest = <B as Requester>::DeclineChatJoinRequest;
B: Requester, type Err = <B as Requester>::Err; type GetMe = <B as Requester>::GetMe; type LogOut = <B as Requester>::LogOut; type Close = <B as Requester>::Close; type GetUpdates = <B as Requester>::GetUpdates; type SetWebhook = <B as Requester>::SetWebhook; type DeleteWebhook = <B as Requester>::DeleteWebhook; type GetWebhookInfo = <B as Requester>::GetWebhookInfo; type ForwardMessage = <B as Requester>::ForwardMessage; type CopyMessage = <B as Requester>::CopyMessage; type SendMessage = <B as Requester>::SendMessage; type SendPhoto = <B as Requester>::SendPhoto; type SendAudio = <B as Requester>::SendAudio; type SendDocument = <B as Requester>::SendDocument; type SendVideo = <B as Requester>::SendVideo; type SendAnimation = <B as Requester>::SendAnimation; type SendVoice = <B as Requester>::SendVoice; type SendVideoNote = <B as Requester>::SendVideoNote; type SendMediaGroup = <B as Requester>::SendMediaGroup; type SendLocation = <B as Requester>::SendLocation; type EditMessageLiveLocation = <B as Requester>::EditMessageLiveLocation; type EditMessageLiveLocationInline = <B as Requester>::EditMessageLiveLocationInline; type StopMessageLiveLocation = <B as Requester>::StopMessageLiveLocation; type StopMessageLiveLocationInline = <B as Requester>::StopMessageLiveLocationInline; type SendVenue = <B as Requester>::SendVenue; type SendContact = <B as Requester>::SendContact; type SendPoll = <B as Requester>::SendPoll; type SendDice = <B as Requester>::SendDice; type SendChatAction = <B as Requester>::SendChatAction; type GetUserProfilePhotos = <B as Requester>::GetUserProfilePhotos; type GetFile = <B as Requester>::GetFile; type KickChatMember = <B as Requester>::KickChatMember; type BanChatMember = <B as Requester>::BanChatMember; type UnbanChatMember = <B as Requester>::UnbanChatMember; type RestrictChatMember = <B as Requester>::RestrictChatMember; type PromoteChatMember = <B as Requester>::PromoteChatMember; type SetChatAdministratorCustomTitle = <B as Requester>::SetChatAdministratorCustomTitle; type BanChatSenderChat = <B as Requester>::BanChatSenderChat; type UnbanChatSenderChat = <B as Requester>::UnbanChatSenderChat; type SetChatPermissions = <B as Requester>::SetChatPermissions; type ExportChatInviteLink = <B as Requester>::ExportChatInviteLink; type CreateChatInviteLink = <B as Requester>::CreateChatInviteLink; type EditChatInviteLink = <B as Requester>::EditChatInviteLink; type RevokeChatInviteLink = <B as Requester>::RevokeChatInviteLink; type SetChatPhoto = <B as Requester>::SetChatPhoto; type DeleteChatPhoto = <B as Requester>::DeleteChatPhoto; type SetChatTitle = <B as Requester>::SetChatTitle; type SetChatDescription = <B as Requester>::SetChatDescription; type PinChatMessage = <B as Requester>::PinChatMessage; type UnpinChatMessage = <B as Requester>::UnpinChatMessage; type UnpinAllChatMessages = <B as Requester>::UnpinAllChatMessages; type LeaveChat = <B as Requester>::LeaveChat; type GetChat = <B as Requester>::GetChat; type GetChatAdministrators = <B as Requester>::GetChatAdministrators; type GetChatMembersCount = <B as Requester>::GetChatMembersCount; type GetChatMemberCount = <B as Requester>::GetChatMemberCount; type GetChatMember = <B as Requester>::GetChatMember; type SetChatStickerSet = <B as Requester>::SetChatStickerSet; type DeleteChatStickerSet = <B as Requester>::DeleteChatStickerSet; type AnswerCallbackQuery = <B as Requester>::AnswerCallbackQuery; type SetMyCommands = <B as Requester>::SetMyCommands; type GetMyCommands = <B as Requester>::GetMyCommands; type SetChatMenuButton = <B as Requester>::SetChatMenuButton; type GetChatMenuButton = <B as Requester>::GetChatMenuButton; type SetMyDefaultAdministratorRights = <B as Requester>::SetMyDefaultAdministratorRights; type GetMyDefaultAdministratorRights = <B as Requester>::GetMyDefaultAdministratorRights; type DeleteMyCommands = <B as Requester>::DeleteMyCommands; type AnswerInlineQuery = <B as Requester>::AnswerInlineQuery; type AnswerWebAppQuery = <B as Requester>::AnswerWebAppQuery; type EditMessageText = <B as Requester>::EditMessageText; type EditMessageTextInline = <B as Requester>::EditMessageTextInline; type EditMessageCaption = <B as Requester>::EditMessageCaption; type EditMessageCaptionInline = <B as Requester>::EditMessageCaptionInline; type EditMessageMedia = <B as Requester>::EditMessageMedia; type EditMessageMediaInline = <B as Requester>::EditMessageMediaInline; type EditMessageReplyMarkup = <B as Requester>::EditMessageReplyMarkup; type EditMessageReplyMarkupInline = <B as Requester>::EditMessageReplyMarkupInline; type StopPoll = <B as Requester>::StopPoll; type DeleteMessage = <B as Requester>::DeleteMessage; type SendSticker = <B as Requester>::SendSticker; type GetStickerSet = <B as Requester>::GetStickerSet; type GetCustomEmojiStickers = <B as Requester>::GetCustomEmojiStickers; type UploadStickerFile = <B as Requester>::UploadStickerFile; type CreateNewStickerSet = <B as Requester>::CreateNewStickerSet; type AddStickerToSet = <B as Requester>::AddStickerToSet; type SetStickerPositionInSet = <B as Requester>::SetStickerPositionInSet; type DeleteStickerFromSet = <B as Requester>::DeleteStickerFromSet; type SetStickerSetThumb = <B as Requester>::SetStickerSetThumb; type SendInvoice = <B as Requester>::SendInvoice; type CreateInvoiceLink = <B as Requester>::CreateInvoiceLink; type AnswerShippingQuery = <B as Requester>::AnswerShippingQuery; type AnswerPreCheckoutQuery = <B as Requester>::AnswerPreCheckoutQuery; type SetPassportDataErrors = <B as Requester>::SetPassportDataErrors; type SendGame = <B as Requester>::SendGame; type SetGameScore = <B as Requester>::SetGameScore; type SetGameScoreInline = <B as Requester>::SetGameScoreInline; type GetGameHighScores = <B as Requester>::GetGameHighScores; type ApproveChatJoinRequest = <B as Requester>::ApproveChatJoinRequest; type DeclineChatJoinRequest = <B as Requester>::DeclineChatJoinRequest;
Get the value. Read more
sourceimpl<T> Insert<T> for DependencyMapwhere
T: 'static + Send + Sync,
impl<T> Insert<T> for DependencyMapwhere
T: 'static + Send + Sync,
sourceimpl PartialEq<DependencyMap> for DependencyMap
impl PartialEq<DependencyMap> for DependencyMap
sourcefn eq(&self, other: &DependencyMap) -> bool
fn eq(&self, other: &DependencyMap) -> bool
Auto Trait Implementations
impl !RefUnwindSafe for DependencyMap
impl Send for DependencyMap
impl Sync for DependencyMap
impl Unpin for DependencyMap
impl !UnwindSafe for DependencyMap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more