esp_idf_svc::http::headers

Type Alias ContentLenParseBuf

Source
pub type ContentLenParseBuf = String<20>;

Aliased Type§

struct ContentLenParseBuf { /* private fields */ }

Implementations

Source§

impl<const N: usize> String<N>

Source

pub const fn new() -> String<N>

Constructs a new, empty String with a fixed capacity of N bytes

§Examples

Basic usage:

use heapless::String;

// allocate the string on the stack
let mut s: String<4> = String::new();

// allocate the string in a static variable
static mut S: String<4> = String::new();
Source

pub fn from_utf8(vec: Vec<u8, N>) -> Result<String<N>, Utf8Error>

Convert UTF-8 bytes into a String.

§Examples

Basic usage:

use heapless::{String, Vec};

let mut sparkle_heart = Vec::<u8, 4>::new();
sparkle_heart.extend_from_slice(&[240, 159, 146, 150]);

let sparkle_heart: String<4> = String::from_utf8(sparkle_heart)?;
assert_eq!("💖", sparkle_heart);

Invalid UTF-8:

use core::str::Utf8Error;
use heapless::{String, Vec};

let mut vec = Vec::<u8, 4>::new();
vec.extend_from_slice(&[0, 159, 146, 150]);

let e: Utf8Error = String::from_utf8(vec).unwrap_err();
assert_eq!(e.valid_up_to(), 1);
Source

pub unsafe fn from_utf8_unchecked(vec: Vec<u8, N>) -> String<N>

Convert UTF-8 bytes into a String, without checking that the string contains valid UTF-8.

§Safety

The bytes passed in must be valid UTF-8.

§Examples

Basic usage:

use heapless::{String, Vec};

let mut sparkle_heart = Vec::<u8, 4>::new();
sparkle_heart.extend_from_slice(&[240, 159, 146, 150]);

// Safety: `sparkle_heart` Vec is known to contain valid UTF-8
let sparkle_heart: String<4> = unsafe { String::from_utf8_unchecked(sparkle_heart) };
assert_eq!("💖", sparkle_heart);
Source

pub fn into_bytes(self) -> Vec<u8, N>

Converts a String into a byte vector.

This consumes the String, so we do not need to copy its contents.

§Examples

Basic usage:

use heapless::String;

let s: String<4> = String::try_from("ab")?;
let b = s.into_bytes();
assert!(b.len() == 2);

assert_eq!(&['a' as u8, 'b' as u8], &b[..]);
Source

pub fn as_str(&self) -> &str

Extracts a string slice containing the entire string.

§Examples

Basic usage:

use heapless::String;

let mut s: String<4> = String::try_from("ab")?;
assert!(s.as_str() == "ab");

let _s = s.as_str();
// s.push('c'); // <- cannot borrow `s` as mutable because it is also borrowed as immutable
Source

pub fn as_mut_str(&mut self) -> &mut str

Converts a String into a mutable string slice.

§Examples

Basic usage:

use heapless::String;

let mut s: String<4> = String::try_from("ab")?;
let s = s.as_mut_str();
s.make_ascii_uppercase();
Source

pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8, N>

Returns a mutable reference to the contents of this String.

§Safety

This function is unsafe because it does not check that the bytes passed to it are valid UTF-8. If this constraint is violated, it may cause memory unsafety issues with future users of the String, as the rest of the library assumes that Strings are valid UTF-8.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("hello")?;

unsafe {
    let vec = s.as_mut_vec();
    assert_eq!(&[104, 101, 108, 108, 111][..], &vec[..]);

    vec.reverse();
}
assert_eq!(s, "olleh");
Source

pub fn push_str(&mut self, string: &str) -> Result<(), ()>

Appends a given string slice onto the end of this String.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("foo")?;

assert!(s.push_str("bar").is_ok());

assert_eq!("foobar", s);

assert!(s.push_str("tender").is_err());
Source

pub fn capacity(&self) -> usize

Returns the maximum number of elements the String can hold

§Examples

Basic usage:

use heapless::String;

let mut s: String<4> = String::new();
assert!(s.capacity() == 4);
Source

pub fn push(&mut self, c: char) -> Result<(), ()>

Appends the given [char] to the end of this String.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("abc")?;

s.push('1').unwrap();
s.push('2').unwrap();
s.push('3').unwrap();

assert!("abc123" == s.as_str());

assert_eq!("abc123", s);
Source

pub fn truncate(&mut self, new_len: usize)

Shortens this String to the specified length.

If new_len is greater than the string’s current length, this has no effect.

Note that this method has no effect on the allocated capacity of the string

§Panics

Panics if new_len does not lie on a [char] boundary.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("hello")?;

s.truncate(2);

assert_eq!("he", s);
Source

pub fn pop(&mut self) -> Option<char>

Removes the last character from the string buffer and returns it.

Returns [None] if this String is empty.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("foo")?;

assert_eq!(s.pop(), Some('o'));
assert_eq!(s.pop(), Some('o'));
assert_eq!(s.pop(), Some('f'));

assert_eq!(s.pop(), None);
Ok::<(), ()>(())
Source

pub fn remove(&mut self, index: usize) -> char

Removes a [char] from this String at a byte position and returns it.

Note: Because this shifts over the remaining elements, it has a worst-case performance of O(n).

§Panics

Panics if idx is larger than or equal to the String’s length, or if it does not lie on a [char] boundary.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("foo").unwrap();

assert_eq!(s.remove(0), 'f');
assert_eq!(s.remove(1), 'o');
assert_eq!(s.remove(0), 'o');
Source

pub fn clear(&mut self)

Truncates this String, removing all contents.

While this means the String will have a length of zero, it does not touch its capacity.

§Examples

Basic usage:

use heapless::String;

let mut s: String<8> = String::try_from("foo")?;

s.clear();

assert!(s.is_empty());
assert_eq!(0, s.len());
assert_eq!(8, s.capacity());
Ok::<(), ()>(())

Trait Implementations

Source§

impl<const N: usize> AsRef<[u8]> for String<N>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize> AsRef<str> for String<N>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize> Clone for String<N>

Source§

fn clone(&self) -> String<N>

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for String<N>

Source§

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

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

impl<const N: usize> Default for String<N>

Source§

fn default() -> String<N>

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

impl<const N: usize> Deref for String<N>

Source§

type Target = str

The resulting type after dereferencing.
Source§

fn deref(&self) -> &str

Dereferences the value.
Source§

impl<const N: usize> DerefMut for String<N>

Source§

fn deref_mut(&mut self) -> &mut str

Mutably dereferences the value.
Source§

impl<const N: usize> Display for String<N>

Source§

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

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

impl<'a, const N: usize> FromIterator<&'a char> for String<N>

Source§

fn from_iter<T>(iter: T) -> String<N>
where T: IntoIterator<Item = &'a char>,

Creates a value from an iterator. Read more
Source§

impl<'a, const N: usize> FromIterator<&'a str> for String<N>

Source§

fn from_iter<T>(iter: T) -> String<N>
where T: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
Source§

impl<const N: usize> FromIterator<char> for String<N>

Source§

fn from_iter<T>(iter: T) -> String<N>
where T: IntoIterator<Item = char>,

Creates a value from an iterator. Read more
Source§

impl<const N: usize> FromStr for String<N>

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<String<N>, <String<N> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<const N: usize> Hash for String<N>

Source§

fn hash<H>(&self, hasher: &mut H)
where H: Hasher,

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

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl<const N: usize> Ord for String<N>

Source§

fn cmp(&self, other: &String<N>) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<const N: usize> PartialEq<&str> for String<N>

Source§

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

Tests for self and other values to be equal, and is used by ==.
Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N1: usize, const N2: usize> PartialEq<String<N2>> for String<N1>

Source§

fn eq(&self, rhs: &String<N2>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, rhs: &String<N2>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> PartialEq<str> for String<N>

Source§

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

Tests for self and other values to be equal, and is used by ==.
Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N1: usize, const N2: usize> PartialOrd<String<N2>> for String<N1>

Source§

fn partial_cmp(&self, other: &String<N2>) -> Option<Ordering>

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

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, const N: usize> TryFrom<&'a str> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( s: &'a str, ) -> Result<String<N>, <String<N> as TryFrom<&'a str>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<i16> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: i16) -> Result<String<N>, <String<N> as TryFrom<i16>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<i32> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: i32) -> Result<String<N>, <String<N> as TryFrom<i32>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<i64> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: i64) -> Result<String<N>, <String<N> as TryFrom<i64>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<i8> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: i8) -> Result<String<N>, <String<N> as TryFrom<i8>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<u16> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: u16) -> Result<String<N>, <String<N> as TryFrom<u16>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<u32> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: u32) -> Result<String<N>, <String<N> as TryFrom<u32>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<u64> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: u64) -> Result<String<N>, <String<N> as TryFrom<u64>>::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<u8> for String<N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(s: u8) -> Result<String<N>, <String<N> as TryFrom<u8>>::Error>

Performs the conversion.
Source§

impl<const N: usize> Write for String<N>

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a [char] into this writer, returning whether the write succeeded. Read more
1.0.0§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the [write!] macro with implementors of this trait. Read more
Source§

impl<const N: usize> Eq for String<N>