[][src]Module tracers_core::argtypes

This module and its submodules implement a type-safe wrapper around Rust types such that any suitable type can be passed as a parameter to the C probing libraries with a minimum of overhead.

In order to be able to use a type as a probe argument, that type T must implement ProbeArgType<T>, and there must be an implementation of ProbeArgWrapper suitable for that type.

This library provides implementations for all of the following:

  • All integer types from u8/i8 to u64/i64
  • bool (passed as an i32 1 means true and 0 means false)
  • String references &str
  • C-style string references &CStr
  • Option<T> for any T which is itself a supported probe argument type and implements Copy
  • Any pointer type, which is passed as either a 32- or 64-bit unsigned int depending upon architecture

Re-exports

pub use self::bool::*;
pub use cstring::*;
pub use int::*;
pub use native::*;
pub use option::*;
pub use pointer::*;
pub use refs::*;
pub use string::*;

Modules

bool
cstring

This module provides an implementation of the arg type plumbing which passes a rust CString to a native C function by simply passing the pointer to the underlying memory. This is inherently unsafe subject to the safety properties of the CString implementation.

int
native

This module implements the marker trait ProbeArgNativeType for those Rust types that correspond directly to C types, and thus are the ultimate result types for any transformation of a Rust type into a value suitable for passing to the C tracing API.

option

This module implements ProbeArgType and ProbeArgWrapper for Option<T> for any T whichwould itself be a valid probe argument type. Well, sort of. That's not entirely true.

pointer
refs

This module ensures that if ProbeArgType and ProbeArgWrapper are implemented for some T, then they are also implemented for &T. This is necessary for convenience and also to support our generialized implementation for Option<T>

string

This module implements ProbeArgType and ProbeArgWrapper for Rust's string types. This implementation will be available for &String and &str on all supported platforms. On the unix family of platforms, &OsString and &OsStr are also supported.

Enums

CType

Traits

ProbeArgNativeType

The other half of ProbeArgNativeTypeInfo, which takes a type parameter and thus adds get_default_value.

ProbeArgNativeTypeInfo

Marker trait which decorates only those std::os::raw types which correspond to C types supported by the C probing APIs. Due to limitations of Rust's type system, this trait is split into two parts: ProbeArgNativeTypeInfo which has no type parameter, and ProbeArgNativeTypewhich extends ProbeArgNativeTypeInfo, takes a type parameter T and therefore adds the get_default_value() method.

ProbeArgType

This trait is defined on any type which is supported as an argument to a probe.

ProbeArgWrapper

This trait, a companion to ProbeArgType, wraps a supported type and on demand converts it to its equivalent C type. For scalar types that are directly supported there is no overhead to this wrapping, but many more complicated types, including Rust string types, need additional logic to produce a NULL-terminated byte array.

Functions

wrap

Helper function to wrap a probe arg in its correspondong wrapper without contorting one's fingers typing angle brackets