Struct Signature

Source
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>

Source

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.

Source

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.

Source

pub fn borrow(&self) -> Signature<'_>

Create a borrowed version of self for repeated use with add_data() or profile().

Source

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().

Source

pub fn profile<F, R>(&self, f: F) -> R
where 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>

Source

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.

Source

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§

Source§

impl<'a> Clone for Signature<'a>

Source§

fn clone(&self) -> Signature<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Signature<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Hash for Signature<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for Signature<'a>

Source§

fn eq(&self, other: &Signature<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Signature<'a>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.