Allow &[bool], since Rust has committed to a 1-byte representation of `bool`.
Re-export several types from `widestring` so that code generated by the
`trace_logging_provider` macro no longer has a direct reference to the
`widestring` crate.

Update docs.
This commit is contained in:
Arlie Davis 2020-06-18 10:38:31 -07:00
Родитель f8d79e5a5e
Коммит 5c48b1e325
7 изменённых файлов: 33 добавлений и 8 удалений

Просмотреть файл

@ -88,9 +88,13 @@ call into ETW to report the event, but there is no guarantee that the event is s
forwarded; events can be dropped if event buffer resources are scarce.
```rust
my_app_events.client_connected(&"192.168.0.42:6667".parse(), false, 100, "OK");
my_app_events.client_connected(None, &"192.168.0.42:6667".parse(), false, 100, "OK");
```
Note that all generated event methods have an added first parameters,
`options: Option<&EventOptions>`. This parameter allows you to override per-event parameters,
such as the event level and event correlation IDs. In most cases, you should pass `None`.
# Supported field types
Only a limited set of field types are supported.
@ -98,8 +102,7 @@ Only a limited set of field types are supported.
* Floating point primitives: `f32`, `f64`
* Architecture-dependent sizes: `usize`, `isize`.
* Boolean: `bool`
* Slices of all of the supported primitives, except for bool: `&[u8]`, `&[u16]`, etc.
`&[bool]` is not supported because `bool` does not have a guaranteed stable representation.
* Slices of all of the supported primitives: `&[u8]`, `&[u16]`, etc.
* Windows `[FILETIME](https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime)`.
The type must be declared _exactly_ as `FILETIME`; type aliases or fully-qualified paths
(such as `winapi::shared::minwindef::FILETIME`) _will not work_. The parameter type in the
@ -134,6 +137,10 @@ These tools can also be used to capture ETW events:
There are other tools, such as the Windows Performance Recorder, which can capture ETW events.
# Ideas for improvement
* Better handling of per-event overrides, rather than using `Option<&EventOptions>`.
# References
* [Event Tracing for Windows (ETW) Simplified](https://support.microsoft.com/en-us/help/2593157/event-tracing-for-windows-etw-simplified)

Просмотреть файл

@ -153,7 +153,7 @@ trait TestManyEvents {
fn arg_usize(a: usize);
fn arg_isize(a: isize);
// fn arg_slice_bool(a: &[bool]);
fn arg_slice_bool(a: &[bool]);
fn arg_slice_u8(a: &[u8]);
fn arg_slice_u16(a: &[u16]);
fn arg_slice_u32(a: &[u32]);

Просмотреть файл

@ -778,9 +778,9 @@ fn parse_event_field(
statements.extend(quote! {
let #field_desc: EventDataDescriptor;
let #field_len: u16;
let #field_u16cstring: ::widestring::U16CString;
let #field_u16cstr: &::widestring::U16CStr;
match ::widestring::U16CString::from_os_str(#field_name) {
let #field_u16cstring: ::win_etw_provider::types::U16CString;
let #field_u16cstr: &::win_etw_provider::types::U16CStr;
match ::win_etw_provider::types::U16CString::from_os_str(#field_name) {
Ok(s) => {
#field_u16cstring = s;
#field_u16cstr = #field_u16cstring.as_ref();

Просмотреть файл

@ -128,6 +128,7 @@ test_case! {
fn arg_usize(a: usize);
fn arg_isize(a: isize);
fn arg_slice_bool(a: &[bool]);
fn arg_slice_u8(a: &[u8]);
fn arg_slice_u16(a: &[u16]);
fn arg_slice_u32(a: &[u32]);

Просмотреть файл

@ -130,6 +130,7 @@ macro_rules! well_known_types {
}
well_known_types! {
bool;
u8; u16; u32; u64;
i8; i16; i32; i64;
f32; f64;

Просмотреть файл

@ -8,15 +8,24 @@
mod guid;
mod provider;
mod types;
pub mod types;
#[doc(inline)]
pub use guid::GUID;
#[doc(inline)]
pub use provider::*;
#[doc(hidden)]
pub use types::*;
#[doc(hidden)]
pub use win_etw_metadata as metadata;
mod data_descriptor;
#[doc(inline)]
pub use data_descriptor::EventDataDescriptor;
/// Errors returned by `win_etw_provider` functions.

Просмотреть файл

@ -1,3 +1,10 @@
//! Contains items that are part of the implementation of `win_etw`, but not intended to be used
//! directly by application code. Only code generated by the `trace_logging_provider` macro
//! should use these types.
#![doc(hidden)]
pub use widestring::{U16CStr, U16CString};
use crate::EventDataDescriptor;
use zerocopy::{AsBytes, FromBytes};