pub struct Signature<'a> { /* private fields */ }
Expand description
A string encoding information about the code being profiled for Godot’s built-in profiler.
The string should be in the form of {file}::{line_number}::{tag}
, where tag
is an
identifier of the code, usually be the name of the method. None of the substrings should
contain ::
.
To create a Signature
in the correct form, see Signature::new()
or profile_sig!
. To
create a Signature
from an existing CStr
or CString
, see Signature::from_raw()
and
Signature::from_raw_owned()
.
Implementations§
Source§impl<'a> Signature<'a>
impl<'a> Signature<'a>
Sourcepub const fn from_raw(sig: &'a CStr) -> Self
pub const fn from_raw(sig: &'a CStr) -> Self
Creates a Signature
from a CStr
in the specified format. The format is not
checked.
Adding profiling data using an invalid Signature
may cause incorrect information to
show up in the editor.
Sourcepub unsafe fn from_bytes_with_nul_unchecked(bytes: &'a [u8]) -> Self
pub unsafe fn from_bytes_with_nul_unchecked(bytes: &'a [u8]) -> Self
Creates a Signature
from a NUL-terminated byte slice, containing a string in the
specified format. Neither the format nor whether the slice is correctly NUL-terminated
is checked.
This is a convenience method for Signature::from_raw(CStr::from_bytes_with_nul_unchecked(bytes))
.
Adding profiling data using an invalid Signature
may cause incorrect information to
show up in the editor.
§Safety
This function will cast the provided bytes
to a CStr
wrapper without performing any
sanity checks. The provided slice must be nul-terminated and not contain any
interior nul bytes.
Sourcepub fn borrow(&self) -> Signature<'_>
pub fn borrow(&self) -> Signature<'_>
Create a borrowed version of self
for repeated use with add_data()
or profile()
.
Sourcepub fn add_data(&self, time: Duration)
pub fn add_data(&self, time: Duration)
Add a data point to Godot’s built-in profiler using this signature.
See the free function profiler::add_data()
.
Sourcepub fn profile<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn profile<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
Times a closure and adds the measured time to Godot’s built-in profiler with this signature, and then returns it’s return value.
See the free function profiler::profile()
.
Source§impl Signature<'static>
impl Signature<'static>
Sourcepub fn new(file: &str, line: u32, tag: &str) -> Self
pub fn new(file: &str, line: u32, tag: &str) -> Self
Creates a Signature
in the correct form using the given variables. The format is
checked at runtime.
§Panics
If file
or tag
contain ::
or NUL-bytes.
Sourcepub const fn from_raw_owned(sig: CString) -> Self
pub const fn from_raw_owned(sig: CString) -> Self
Creates a Signature
from an owned CString
in the specified format. The format is not
checked.
Adding profiling data using an invalid Signature
may cause incorrect information to
show up in the editor.
Trait Implementations§
impl<'a> Eq for Signature<'a>
impl<'a> StructuralPartialEq for Signature<'a>
Auto Trait Implementations§
impl<'a> Freeze for Signature<'a>
impl<'a> RefUnwindSafe for Signature<'a>
impl<'a> Send for Signature<'a>
impl<'a> Sync for Signature<'a>
impl<'a> Unpin for Signature<'a>
impl<'a> UnwindSafe for Signature<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.