-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lib): move resource builder into own lib
As the code is likely to grow far more complex, it's required to move it as long as it is easy to do so.
- Loading branch information
Showing
4 changed files
with
147 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<%! | ||
from util import (put_and, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, | ||
mb_type, singular, hub_type) | ||
%>\ | ||
<%namespace name="util" file="util.mako"/>\ | ||
<%namespace name="lib" file="lib.mako"/>\ | ||
|
||
## Creates a Resource builder type | ||
############################################################################################### | ||
############################################################################################### | ||
<%def name="new(resource, c)">\ | ||
<% hub_type_name = hub_type(canonicalName) %> | ||
/// A builder providing access to all methods supported on *${singular(resource)}* resources. | ||
/// It is usually not used directly, but through the `${hub_type_name}` hub. | ||
/// | ||
/// # Example | ||
/// | ||
/// Instantiate a resource builder | ||
/// | ||
<%block filter="rust_doc_test_norun, rust_doc_comment">\ | ||
${util.test_prelude()}\ | ||
<%block filter="rust_test_fn_invisible">\ | ||
${lib.test_hub(hub_type_name)}\ | ||
// Usually you wouldn't stick this into a variable, but keep calling `MethodBuilders` | ||
// like ${put_and(sorted('`%s(...)`' % f for f in c.rta_map[resource]))} | ||
let rb = hub.${resource}(); | ||
</%block> | ||
</%block> | ||
pub struct ${mb_type(resource)}<'a, C, NC, A> | ||
where NC: 'a, | ||
C: 'a, | ||
A: 'a, { | ||
hub: &'a ${hub_type_name}<C, NC, A> | ||
} | ||
impl<'a, C, NC, A> MethodBuilder for ${mb_type(resource)}<'a, C, NC, A> {} | ||
</%def> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters