Struct gdnative::prelude::NodePath

source ·
pub struct NodePath(_);
Expand description

A reference-counted relative or absolute path in a scene tree, for use with Node.get_node() and similar functions. It can reference a node, a resource within a node, or a property of a node or resource.

"Path2D/PathFollow2D/Sprite:texture:size" would refer to the size property of the texture resource on the node named “Sprite” which is a child of the other named nodes in the path. Note that if you want to get a resource, you must end the path with a colon, otherwise the last element will be used as a property name.

If a string is passed to Node.get_node(), it will be automatically converted to a NodePath, but NodePath can be parsed ahead of time with NodePath::from_str or NodePath::new.

A NodePath consists of node names, “sub-node” (resource) names, and the name of a property in the final node or resource.

More info at Godot’s official documentation

Implementations§

source§

impl NodePath

source

pub fn from_str(path: &str) -> NodePath

Create a NodePath from a string, e.g. "Path2D/PathFollow2D/Sprite:texture:size". A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, "." and ".." indicate the current node and its parent.

source

pub fn new(path: &GodotString) -> NodePath

Create a NodePath from a GodotString.

source

pub fn is_empty(&self) -> bool

Returns true if the node path is empty.

source

pub fn is_absolute(&self) -> bool

Returns true if the node path is absolute.

source

pub fn name_count(&mut self) -> i32

Get the number of node names which make up the path.

source

pub fn get_subname(&self, idx: i32) -> GodotString

Returns the resource name of the specified idx, 0 to subname_count()

source

pub fn get_subname_count(&self) -> i32

Returns the number of resource names in the path.

source

pub fn get_concatenated_subnames(&self) -> GodotString

source

pub fn to_godot_string(&self) -> GodotString

Returns the NodePath as a GodotString

Trait Implementations§

source§

impl CoerceFromVariant for NodePath

source§

impl Debug for NodePath

source§

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

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

impl Default for NodePath

source§

fn default() -> NodePath

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for NodePath

source§

fn deserialize<D>(
    deserializer: D
) -> Result<NodePath, <D as Deserializer<'de>>::Error>where
    D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Drop for NodePath

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Export for NodePath

§

type Hint = NoHint

A type-specific hint type that is valid for the type being exported. Read more
source§

fn export_info(_hint: Option<<NodePath as Export>::Hint>) -> ExportInfo

Returns ExportInfo given an optional typed hint.
source§

impl From<GodotString> for NodePath

source§

fn from(s: GodotString) -> NodePath

Converts to this type from the input type.
source§

impl From<NodePath> for GodotString

source§

fn from(p: NodePath) -> GodotString

Converts to this type from the input type.
source§

impl<S> From<S> for NodePathwhere
    S: AsRef<str>,

source§

fn from(s: S) -> NodePath

Converts to this type from the input type.
source§

impl FromVariant for NodePath

source§

impl NewRef for NodePath

source§

fn new_ref(&self) -> NodePath

Creates a new reference to the underlying object.
source§

impl PartialEq<NodePath> for NodePath

source§

fn eq(&self, other: &NodePath) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for NodePath

source§

fn serialize<S>(
    &self,
    ser: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
    S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToString for NodePath

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl ToVariant for NodePath

source§

impl Eq for NodePath

source§

impl ToVariantEq for NodePath

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere
    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

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> OwnedToVariant for Twhere
    T: ToVariant,

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere
    T: for<'de> Deserialize<'de>,