Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide whether to expose godot_char_string publicly #993

Open
chitoyuu opened this issue Dec 7, 2022 · 2 comments
Open

Decide whether to expose godot_char_string publicly #993

chitoyuu opened this issue Dec 7, 2022 · 2 comments
Labels
c: core Component: core (mod core_types, object, log, init, ...) feature Adds functionality to the library

Comments

@chitoyuu
Copy link
Contributor

chitoyuu commented Dec 7, 2022

Created during survey of commented code (#377).

godot_char_string is a Godot string type representing a byte string of some encoding. It is currently used internally in the #[doc(hidden)] Utf8String type in the conversion process from GodotString to the Rust String.

Reasons we might want this type to become public (likely with a re-designed API):

  • Sake of completeness.
  • Beyond UTF8, Godot also exposes functions to create char_strings in ascii and ascii_extended encodings, that could be interesting.

Reasons we might want to remove it altogether in favor of inline FFI calls in conversion:

  • Extremely narrow API surface of the type that essentially consists of only a &[c_char] getter.
@chitoyuu chitoyuu added feature Adds functionality to the library c: core Component: core (mod core_types, object, log, init, ...) labels Dec 7, 2022
@Bromeon
Copy link
Member

Bromeon commented Dec 7, 2022

For reference, here's the godot-cpp API:

class CharString {
	friend class String;

	godot_char_string _char_string;

public:
	~CharString();

	int length() const;
	const char *get_data() const;
};

class String {
	...
public:
	CharString utf8() const;
	CharString ascii(bool p_extended = false) const;
}

If this is added, it would need some good documentation to differentiate it from GodotString and StringName. Also, might be rare enough to be hidden in some nested module...

@chitoyuu
Copy link
Contributor Author

chitoyuu commented Dec 8, 2022

It might also be confusing that a CharString won't let you access any Rust chars. Perhaps it's best renamed to ByteString to make that clear?

I agree that it should probably stay out of the prelude at the very least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Component: core (mod core_types, object, log, init, ...) feature Adds functionality to the library
Projects
None yet
Development

No branches or pull requests

2 participants