On-going PR to merge feature-macro branch #91
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is used to ensure
feature-macro
can be merged with main and compile properly.** MUST BE MERGED WITHOUT SQUASHING **
Implement procedure macro support, replacing the need for the build script and the boilerplate code. Includes a testing framework (using insta), reports multiple compiler errors linking to offending code with tests using trybuild, and autogenerated documentation.
All examples have been migrated in the #85
Usage example
Converted Examples
Notes
Ctx
is now optional, and can be both&
and&mut
Cargo.toml
done in Make Serde into an optional dependency #62Tasks
extern "C"
wrapper for each fn (partially done, needs a bit more cleanup)struct VmodExports
with all functions as static callbacks, and instantiate it as global staticVMOD_EXPORTS
.$CPROTO
C header snippet describing function signaturesVmod_{name}_Data
global static instancefn foo(#[arg(default = "arg")], param: &str)
Other Ideas and TODOs
SocketAddr
,Probe
, andCOWProbe
create a bit of confusion because they do not have to be "optional", they can just be nullable, and in Rust nullable and optional is the same thing. This creates a problem if the user wants a function likefoo(ip: SocketAddr, val: i64)
-- the first optional won't work properly unless the second is also optional.Supported types
&Ctx
or&mut Ctx
as input param is supported in all user functions&str
input param for object constructors. Requires#[vcl_name]
attribute.VCL_ACL
*const vrt_acl
VCLBackendPtr
VCL_BACKEND
*const director
VCL_BLOB
*const vrt_blob
VCL_BODY
*const ::std::os::raw::c_void
bool
VCL_BOOL
::std::os::raw::c_uint
VCL_BYTES
Duration
VCL_DURATION
vtim_dur
VCL_ENUM
*const ::std::os::raw::c_char
VCL_HEADER
*const gethdr_s
VCL_HTTP
*mut http
VCL_INSTANCE
::std::os::raw::c_void
i64
VCL_INT
SocketAddr
VCL_IP
*const suckaddr
Probe
VCL_PROBE
*const vrt_backend_probe
COWProbe
f64
VCL_REAL
VCL_REGEX
*const vre
VCL_STEVEDORE
*const stevedore
VCL_STRANDS
*const strands
VCL_STRING
VCL_STRING
*const ::std::os::raw::c_char
&str
String
&CStr
CString
VCL_SUB
*const vcl_sub
VCL_TIME
vtim_real
VCL_VCL
*mut vcl
VCL_VOID
::std::os::raw::c_void
i8
i16
i32
i128
isize
u8
u16
u32
u64
u128
usize
[u8]
Vec<u8>
Box<dyn Error>
3#[arg(default = ...)]
attribute, allowing a function to be called from VCL with this argument set to the VMOD-provided default.Option<T>
in Rust code, making it both optional and nullable, e.g.Option<SocketAddr>
.Box<dyn Error>
is a special case, as it is not a Varnish type, but it is a common return type for error handling in Rust. It is supported as an error return type, but not as an input or output type.Closes #73