Skip to content

Commit

Permalink
deploy: 1f8515b
Browse files Browse the repository at this point in the history
  • Loading branch information
nyospe committed Mar 1, 2024
1 parent e0bb82e commit db29ffe
Show file tree
Hide file tree
Showing 108 changed files with 759 additions and 487 deletions.
2 changes: 1 addition & 1 deletion search-index.js

Large diffs are not rendered by default.

216 changes: 150 additions & 66 deletions src/tide_disco/api.rs.html

Large diffs are not rendered by default.

112 changes: 76 additions & 36 deletions src/tide_disco/app.rs.html

Large diffs are not rendered by default.

44 changes: 36 additions & 8 deletions src/tide_disco/lib.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,20 @@
<a href="#678" id="678">678</a>
<a href="#679" id="679">679</a>
<a href="#680" id="680">680</a>
<a href="#681" id="681">681</a>
<a href="#682" id="682">682</a>
<a href="#683" id="683">683</a>
<a href="#684" id="684">684</a>
<a href="#685" id="685">685</a>
<a href="#686" id="686">686</a>
<a href="#687" id="687">687</a>
<a href="#688" id="688">688</a>
<a href="#689" id="689">689</a>
<a href="#690" id="690">690</a>
<a href="#691" id="691">691</a>
<a href="#692" id="692">692</a>
<a href="#693" id="693">693</a>
<a href="#694" id="694">694</a>
</pre></div><pre class="rust"><code><span class="comment">// Copyright (c) 2022 Espresso Systems (espressosys.com)
// This file is part of the tide-disco library.

Expand Down Expand Up @@ -731,11 +745,13 @@
//!
//! type State = ();
//! type Error = ServerError;
//! const MAJOR: u16 = 0;
//! const MINOR: u16 = 1;
//!
//! let spec: toml::Value = toml::from_str(
//! std::str::from_utf8(&amp;std::fs::read("/path/to/api.toml").unwrap()).unwrap(),
//! ).unwrap();
//! let mut api = Api::&lt;State, Error&gt;::new(spec)?;
//! let mut api = Api::&lt;State, Error, MAJOR, MINOR&gt;::new(spec)?;
//! # Ok(())
//! # }
//! ```
Expand All @@ -753,9 +769,11 @@
//!
//! ```no_run
//! # use tide_disco::Api;
//! # const MAJOR: u16 = 0;
//! # const MINOR: u16 = 1;
//! # fn main() -&gt; Result&lt;(), tide_disco::api::ApiError&gt; {
//! # let spec: toml::Value = toml::from_str(std::str::from_utf8(&amp;std::fs::read("/path/to/api.toml").unwrap()).unwrap()).unwrap();
//! # let mut api = Api::&lt;(), tide_disco::error::ServerError&gt;::new(spec)?;
//! # let mut api = Api::&lt;(), tide_disco::error::ServerError, MAJOR, MINOR&gt;::new(spec)?;
//! use futures::FutureExt;
//!
//! api.get("hello", |req, state| async move { Ok("Hello, world!") }.boxed())?;
Expand All @@ -771,12 +789,17 @@
//! ```no_run
//! # type State = ();
//! # type Error = tide_disco::error::ServerError;
//! # const MAJOR: u16 = 0;
//! # const MINOR: u16 = 1;
//! # #[async_std::main] async fn main() {
//! # let spec: toml::Value = toml::from_str(std::str::from_utf8(&amp;std::fs::read("/path/to/api.toml").unwrap()).unwrap()).unwrap();
//! # let api = tide_disco::Api::&lt;State, Error&gt;::new(spec).unwrap();
//! # let api = tide_disco::Api::&lt;State, Error, MAJOR, MINOR&gt;::new(spec).unwrap();
//! use tide_disco::App;
//!
//! let mut app = App::&lt;State, Error&gt;::with_state(());
//! const MAJOR: u16 = 0;
//! const MINOR: u16 = 1;
//!
//! let mut app = App::&lt;State, Error, MAJOR, MINOR&gt;::with_state(());
//! app.register_module("api", api);
//! app.serve("http://localhost:8080").await;
//! # }
Expand Down Expand Up @@ -839,7 +862,7 @@
//! implements [Fn], not just static function pointers. Here is what we would _like_ to write:
//!
//! ```ignore
//! impl&lt;State, Error&gt; Api&lt;State, Error&gt; {
//! impl&lt;State, Error, const MAJOR: u16, const MINOR: u16&gt; Api&lt;State, Error, MAJOR, MINOR&gt; {
//! pub fn at&lt;F, T&gt;(&amp;mut self, route: &amp;str, handler: F)
//! where
//! F: for&lt;'a&gt; Fn&lt;(RequestParams, &amp;'a State)&gt;,
Expand All @@ -864,7 +887,7 @@
//! `F`. Here is the actual (partial) signature of [at](Api::at):
//!
//! ```ignore
//! impl&lt;State, Error&gt; Api&lt;State, Error&gt; {
//! impl&lt;State, Error, const MAJOR: u16, const MINOR: u16&gt; Api&lt;State, Error, MAJOR, MINOR&gt; {
//! pub fn at&lt;F, T&gt;(&amp;mut self, route: &amp;str, handler: F)
//! where
//! F: for&lt;'a&gt; Fn(RequestParams, &amp;'a State) -&gt; BoxFuture&lt;'a, Result&lt;T, Error&gt;&gt;,
Expand All @@ -884,7 +907,10 @@
//! type State = RwLock&lt;u64&gt;;
//! type Error = ();
//!
//! fn define_routes(api: &amp;mut Api&lt;State, Error&gt;) {
//! const MAJOR: u16 = 0;
//! const MINOR: u16 = 1;
//!
//! fn define_routes(api: &amp;mut Api&lt;State, Error, MAJOR, MINOR&gt;) {
//! api.at("someroute", |_req, state: &amp;State| async {
//! Ok(*state.read().await)
//! }.boxed());
Expand All @@ -902,12 +928,14 @@
//!
//! type State = RwLock&lt;u64&gt;;
//! type Error = ();
//! const MAJOR: u16 = 0;
//! const MINOR: u16 = 1;
//!
//! async fn handler(_req: RequestParams, state: &amp;State) -&gt; Result&lt;u64, Error&gt; {
//! Ok(*state.read().await)
//! }
//!
//! fn register(api: &amp;mut Api&lt;State, Error&gt;) {
//! fn register(api: &amp;mut Api&lt;State, Error, MAJOR, MINOR&gt;) {
//! api.at("someroute", |req, state: &amp;State| handler(req, state).boxed());
//! }
//! ```
Expand Down
4 changes: 3 additions & 1 deletion src/tide_disco/metrics.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<a href="#81" id="81">81</a>
<a href="#82" id="82">82</a>
<a href="#83" id="83">83</a>
<a href="#84" id="84">84</a>
</pre></div><pre class="rust"><code><span class="comment">// Copyright (c) 2022 Espresso Systems (espressosys.com)
// This file is part of the tide-disco library.

Expand Down Expand Up @@ -138,7 +139,8 @@
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">struct </span>Handler&lt;F&gt;(F);

<span class="attr">#[async_trait]
</span><span class="kw">impl</span>&lt;F, T, State, Error&gt; route::Handler&lt;State, Error&gt; <span class="kw">for </span>Handler&lt;F&gt;
</span><span class="kw">impl</span>&lt;F, T, State, Error, <span class="kw">const </span>MAJOR: u16, <span class="kw">const </span>MINOR: u16&gt;
route::Handler&lt;State, Error, MAJOR, MINOR&gt; <span class="kw">for </span>Handler&lt;F&gt;
<span class="kw">where
</span>F: <span class="lifetime">'static </span>+ Send + Sync + Fn(RequestParams, <span class="kw-2">&amp;</span>State::State) -&gt; BoxFuture&lt;<span class="prelude-ty">Result</span>&lt;Cow&lt;T&gt;, Error&gt;&gt;,
T: <span class="lifetime">'static </span>+ Clone + Metrics,
Expand Down
12 changes: 8 additions & 4 deletions src/tide_disco/request.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,8 @@
<a href="#846" id="846">846</a>
<a href="#847" id="847">847</a>
<a href="#848" id="848">848</a>
<a href="#849" id="849">849</a>
<a href="#850" id="850">850</a>
</pre></div><pre class="rust"><code><span class="comment">// Copyright (c) 2022 Espresso Systems (espressosys.com)
// This file is part of the tide-disco library.

Expand All @@ -862,6 +864,7 @@
<span class="kw">use </span>strum_macros::EnumString;
<span class="kw">use </span>tagged_base64::TaggedBase64;
<span class="kw">use </span>tide::http::{<span class="self">self</span>, content::Accept, mime::Mime, Headers};
<span class="kw">use </span>versioned_binary_serialization::{BinarySerializer, Serializer};

<span class="attr">#[derive(Clone, Debug, Snafu, Deserialize, Serialize)]
</span><span class="kw">pub enum </span>RequestError {
Expand All @@ -884,8 +887,8 @@
<span class="attr">#[snafu(display(<span class="string">"Unable to deserialize from JSON"</span>))]
</span>Json,

<span class="attr">#[snafu(display(<span class="string">"Unable to deserialize from bincode"</span>))]
</span>Bincode,
<span class="attr">#[snafu(display(<span class="string">"Unable to deserialize from binary"</span>))]
</span>Binary,

<span class="attr">#[snafu(display(<span class="string">"Unable to deserialise from tagged base 64: {}"</span>, reason))]
</span>TaggedBase64 { reason: String },
Expand Down Expand Up @@ -1252,7 +1255,7 @@
<span class="doccomment">/// Deserialize the body of a request.
///
/// The Content-Type header is used to determine the serialization format.
</span><span class="kw">pub fn </span>body_auto&lt;T&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;T, RequestError&gt;
</span><span class="kw">pub fn </span>body_auto&lt;T, <span class="kw">const </span>MAJOR: u16, <span class="kw">const </span>MINOR: u16&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;T, RequestError&gt;
<span class="kw">where
</span>T: serde::de::DeserializeOwned,
{
Expand All @@ -1261,7 +1264,8 @@
<span class="string">"application/json" </span>=&gt; <span class="self">self</span>.body_json(),
<span class="string">"application/octet-stream" </span>=&gt; {
<span class="kw">let </span>bytes = <span class="self">self</span>.body_bytes();
bincode::deserialize(<span class="kw-2">&amp;</span>bytes).map_err(|_err| RequestError::Bincode {})
Serializer::&lt;MAJOR, MINOR&gt;::deserialize(<span class="kw-2">&amp;</span>bytes)
.map_err(|_err| RequestError::Binary {})
}
_content_type =&gt; <span class="prelude-val">Err</span>(RequestError::UnsupportedContentType {}),
}
Expand Down
Loading

0 comments on commit db29ffe

Please sign in to comment.