| 1 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/; |
| 2 | |
| 3 | use fluent_urirust-analyzer cargo fluent-uri 0.4.1 crate/::Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#; |
| 4 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#; |
| 5 | |
| 6 | #[cfg(target_family = "wasm")] |
| 7 | pub trait RetrieverBounds {} |
| 8 | |
| 9 | #[cfg(target_family = "wasm")] |
| 10 | impl<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> RetrieverBoundsrust-analyzer cargo referencing 0.37.4 retriever/RetrieverBounds# for T {} |
| 11 | |
| 12 | #[cfg(not(target_family = "wasm"))] |
| 13 | pub trait RetrieverBoundsrust-analyzer cargo referencing 0.37.4 retriever/RetrieverBounds#: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# {} |
| 14 | |
| 15 | #[cfg(not(target_family = "wasm"))] |
| 16 | impl<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#> RetrieverBoundsrust-analyzer cargo referencing 0.37.4 retriever/RetrieverBounds# for T {} |
| 17 | |
| 18 | /// Trait for retrieving resources from external sources. |
| 19 | /// |
| 20 | /// Implementors of this trait can be used to fetch resources that are not |
| 21 | /// initially present in a [`crate::Registry`]. |
| 22 | pub trait Retrieverust-analyzer cargo referencing 0.37.4 retriever/Retrieve#: RetrieverBoundsrust-analyzer cargo referencing 0.37.4 retriever/RetrieverBounds# { |
| 23 | /// Attempt to retrieve a resource from the given URI. |
| 24 | /// |
| 25 | /// # Arguments |
| 26 | /// |
| 27 | /// * `uri` - The URI of the resource to retrieve. |
| 28 | /// |
| 29 | /// # Errors |
| 30 | /// |
| 31 | /// This method can fail for various reasons: |
| 32 | /// - Resource not found |
| 33 | /// - Network errors (for remote resources) |
| 34 | /// - Permission errors |
| 35 | fn retrieverust-analyzer cargo referencing 0.37.4 retriever/Retrieve#retrieve().( |
| 36 | &self, |
| 37 | uri: &Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 38 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>; |
| 39 | } |
| 40 | |
| 41 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 42 | struct DefaultRetrieverErrorrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetrieverError#; |
| 43 | |
| 44 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for DefaultRetrieverErrorrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetrieverError# { |
| 45 | fn fmtrust-analyzer cargo referencing 0.37.4 retriever/impl#[DefaultRetrieverError][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 46 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("Default retriever does not fetch resources") |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for DefaultRetrieverErrorrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetrieverError# {} |
| 51 | |
| 52 | /// A retriever that always fails, used as a default when external resource fetching is not needed. |
| 53 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 54 | pub struct DefaultRetrieverrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetriever#; |
| 55 | |
| 56 | impl Retrieverust-analyzer cargo referencing 0.37.4 retriever/Retrieve# for DefaultRetrieverrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetriever# { |
| 57 | fn retrieverust-analyzer cargo referencing 0.37.4 retriever/impl#[DefaultRetriever][Retrieve]retrieve().(&self, _: &Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>> { |
| 58 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(DefaultRetrieverErrorrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetrieverError#)) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #[cfg(feature = "retrieve-async")] |
| 63 | #[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))] |
| 64 | #[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)] |
| 65 | pub trait AsyncRetrieverust-analyzer cargo referencing 0.37.4 retriever/AsyncRetrieve#: RetrieverBoundsrust-analyzer cargo referencing 0.37.4 retriever/RetrieverBounds# { |
| 66 | /// Asynchronously retrieve a resource from the given URI. |
| 67 | /// |
| 68 | /// This is the non-blocking equivalent of [`Retrieve::retrieve`]. |
| 69 | /// |
| 70 | /// # Arguments |
| 71 | /// |
| 72 | /// * `uri` - The URI of the resource to retrieve. |
| 73 | /// |
| 74 | /// # Errors |
| 75 | /// |
| 76 | /// This method can fail for various reasons: |
| 77 | /// - Resource not found |
| 78 | /// - Network errors (for remote resources) |
| 79 | /// - Permission errors |
| 80 | async fn retrieverust-analyzer cargo referencing 0.37.4 retriever/AsyncRetrieve#retrieve().( |
| 81 | &self, |
| 82 | uri: &Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 83 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>; |
| 84 | } |
| 85 | |
| 86 | #[cfg(feature = "retrieve-async")] |
| 87 | #[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))] |
| 88 | #[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)] |
| 89 | impl AsyncRetrieverust-analyzer cargo referencing 0.37.4 retriever/AsyncRetrieve# for DefaultRetrieverrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetriever# { |
| 90 | async fn retrieverust-analyzer cargo referencing 0.37.4 retriever/impl#[DefaultRetriever][AsyncRetrieve]retrieve().( |
| 91 | &self, |
| 92 | _: &Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 93 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>> { |
| 94 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(DefaultRetrieverErrorrust-analyzer cargo referencing 0.37.4 retriever/DefaultRetrieverError#)) |
| 95 | } |
| 96 | } |