Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-
When implementing properties and methods, follow the HTML spec
-
A helpful resource for translating types from the HTML spec to Rust can be found in the
TypedArray objects
table here -
Try to stay as close as possible to the original JS name while maintaining Rust naming conventions
-
-
You can run
stdweb
's tests withcargo web test --features web_test
This will run them under headless Chromium
-
For concrete Javascript types, define a struct as an
instance_of
the concrete Js typeeg:
#[derive(Clone, Debug, Eq, PartialEq, ReferenceType)] #[reference(instance_of = "CanvasGradient")] pub struct CanvasGradient(Reference);
-
Make sure to document the struct according to the documentation in MDN and provide a link
eg:
/// The CanvasGradient struct represents an opaque object describing a gradient. /// It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or /// CanvasRenderingContext2D.createRadialGradient(). /// /// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient)
Remember these are Rust docs so certain keywords such as
DOMString
andInterface
need to be "translated" into Rust equivalentseg:
`DOMString` -> `String`/`Enum` (whichever is more appropriate) `Interface` -> `trait`
Also add a comment linking the actual HTML spec for that particular object
eg:
// https://html.spec.whatwg.org/#canvasgradient
-
For functions that can't be overloaded properly with traits, define multiple functions with a suffix to specify their use
Try to find one "general" or "basic" function that can take the original non-suffixed name
-
You can export structs and enums by adding them to lib.rs