Struct gdnative_bindings_lily::StreamPeer [−][src]
pub struct StreamPeer { /* fields omitted */ }
Expand description
core class StreamPeer
inherits Reference
(reference counted).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
Memory management
The lifetime of this object is automatically managed through reference counting.
Class hierarchy
StreamPeer inherits methods from:
Safety
All types in the Godot API have “interior mutability” in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
Returns the amount of bytes this StreamPeer has available.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the bytes
argument. If not enough bytes are available, the function will block until the desired amount is received. This function returns two values, an [enum @GlobalScope.Error] code and a data array.
Gets a double-precision float from the stream.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the “bytes” argument. If not enough bytes are available, the function will return how many were actually received. This function returns two values, an [enum @GlobalScope.Error] code, and a data array.
Gets a string with byte-length bytes
from the stream. If bytes
is negative (default) the length will be read from the stream using the reverse process of [method put_string].
Default Arguments
bytes
--1
Gets an UTF-8 string with byte-length bytes
from the stream (this decodes the string sent as UTF-8). If bytes
is negative (default) the length will be read from the stream using the reverse process of [method put_utf8_string].
Default Arguments
bytes
--1
Gets a Variant from the stream. If allow_objects
is true
, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Default Arguments
allow_objects
-false
If true
, this StreamPeer will using big-endian format for encoding and decoding.
Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an [enum @GlobalScope.Error] code.
Puts a double-precision float into the stream.
Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an [enum @GlobalScope.Error] code and an integer, describing how much data was actually sent.
Sample code is GDScript unless otherwise noted.
Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size. Note: To put an ASCII string without prepending its size, you can use [method put_data]:
put_data("Hello world".to_ascii())
Sample code is GDScript unless otherwise noted.
Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size. Note: To put an UTF-8 string without prepending its size, you can use [method put_data]:
put_data("Hello world".to_utf8())
Puts a Variant into the stream. If full_objects
is true
encoding objects is allowed (and can potentially include code).
Default Arguments
full_objects
-false
If true
, this StreamPeer will using big-endian format for encoding and decoding.
Methods from Deref<Target = Reference>
Trait Implementations
type RefKind = RefCounted
type RefKind = RefCounted
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for StreamPeer
impl !Send for StreamPeer
impl !Sync for StreamPeer
impl Unpin for StreamPeer
impl UnwindSafe for StreamPeer