Struct c_fixed_string::CFixedStr [] [src]

pub struct CFixedStr { /* fields omitted */ }

This type represents a view of a fixed length buffer containing a C-style string. The string is terminated by the first null byte in the buffer, or by the length of the buffer if no null byte is present.

The length of the buffer is known as the limit of the CFixedStr. The len() method returns the length of the string within the buffer.

Any bytes after the first null byte are not considered part of the string and may contain garbage data. When comparing or hashing CFixedStrs, these bytes are not included.

Performance

Be aware that many of the methods on this type which would normally be expected to run in constant time may run in time linear in the length of the string. For this reason, it is recommended to use the type only for interop with C code, and to convert to a standard string or byte buffer as soon as possible.

Methods

impl CFixedStr
[src]

[src]

Cast a raw C-style buffer to a CFixedStr.

[src]

Cast a raw C-style buffer to a mutable CFixedStr.

[src]

Create a CFixedStr from a string slice.

[src]

Create a CFixedStr from a byte slice.

[src]

Create a CFixedStr from a mutable byte slice.

[src]

Create a CFixedStr from a variable length CStr.

[src]

Returns the inner pointer to this CFixedStr.

Safety

It is your responsibility to make sure the underlying memory is not freed to early.

[src]

Returns the inner pointer to this mutable CFixedStr.

Safety

It is your responsibility to make sure the underlying memory is not freed to early.

[src]

Returns the limit of this CFixedStr. This corresponds to the longest possible string that could be stored here.

[src]

Returns the length of the CFixedStr. This operation takes linear time.

[src]

Coverts this CFixedStr to a byte slice. The length of the slice is equal to the length of the string up to but not including the first null byte.

[src]

Coverts this CFixedStr to a mutable byte slice. The length of the slice is equal to the length of the string up to but not including the first null byte.

[src]

Coverts this CFixedStr to a byte slice. The length of the slice is equal to the length of the string up to and including the first null byte, if it exists.

[src]

Coverts this CFixedStr to a mutable byte slice. The length of the slice is equal to the length of the string up to and including the first null byte, if it exists.

[src]

Coverts this CFixedStr to a byte slice. The length of the slice is equal to the limit of the CFixedStr.

[src]

Coverts this CFixedStr to a mutable byte slice. The length of the slice is equal to the limit of the CFixedStr.

[src]

Yields a &str slice if the CFixedStr contains valid UTF-8.

This function will calculate the length of this string and check for UTF-8 validity, and then return the &str if it's valid.

[src]

Converts a CFixedStr into a Cow.

This function will calculate the length of this string and then return the resulting slice as a Cow<str>, replacing any invalid UTF-8 sequences with U+FFFD REPLACEMENT CHARACTER.

[src]

Converts a CFixedStr into a Cow.

This function will calculate the length of this string, and then ensure it has a terminating null byte. If a null byte is already present, the Borrowed variant can be returned.

[src]

Converts a Box<CFixedStr> into a CFixedString without copying or allocating.

Trait Implementations

impl Hash for CFixedStr
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for CFixedStr
[src]

[src]

Formats the value using the given formatter.

impl<'a> Default for &'a CFixedStr
[src]

[src]

Returns the "default value" for a type. Read more

impl PartialEq for CFixedStr
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Eq for CFixedStr
[src]

impl PartialOrd for CFixedStr
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for CFixedStr
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl ToOwned for CFixedStr
[src]

[src]

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

[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl AsRef<CFixedStr> for CFixedStr
[src]

[src]

Performs the conversion.