[][src]Function samp::cell::string::put_in_buffer

pub fn put_in_buffer(buffer: &mut Buffer, string: &str) -> Result<(), AmxError>

Fill a buffer with given string.

Example

use samp_sdk::cell::Buffer;
use samp_sdk::cell::string;

// let mut buffer = ...;
// let amx = ...;
let allocator = amx.allocator();
let mut buffer = allocator.allot_buffer(25)?; // let's think that we got a mutable buffer from a native function input.
let string = "Hello, world!".to_string();
string::put_in_buffer(&mut buffer, &string)?; // store string in the AMX heap.

Errors

Return AmxError::General when length of string bytes is more than size of the buffer.