Skip to main content

Flags

Struct Flags 

Source
pub struct Flags(/* private fields */);
Expand description

JSON_* option bits for json_encode, json_decode and json_validate.

PHP passes options as int; Flags::from_php keeps the low 32 bits like the engine’s (int) cast. Unknown bits are ignored.

Implementations§

Source§

impl Flags

Source

pub const NONE: Flags

No options.

Source

pub const OBJECT_AS_ARRAY: Flags

JSON_OBJECT_AS_ARRAY (decode): objects become arrays.

Source

pub const BIGINT_AS_STRING: Flags

JSON_BIGINT_AS_STRING (decode): integers beyond i64 stay strings.

Source

pub const HEX_TAG: Flags

JSON_HEX_TAG: < and > as <, >.

Source

pub const HEX_AMP: Flags

JSON_HEX_AMP: & as &.

Source

pub const HEX_APOS: Flags

JSON_HEX_APOS: ' as '.

Source

pub const HEX_QUOT: Flags

JSON_HEX_QUOT: " as ".

Source

pub const FORCE_OBJECT: Flags

JSON_FORCE_OBJECT: lists as objects.

Source

pub const NUMERIC_CHECK: Flags

JSON_NUMERIC_CHECK: numeric strings as numbers.

Source

pub const UNESCAPED_SLASHES: Flags

JSON_UNESCAPED_SLASHES: / stays /.

Source

pub const PRETTY_PRINT: Flags

JSON_PRETTY_PRINT: newlines and four-space indentation.

Source

pub const UNESCAPED_UNICODE: Flags

JSON_UNESCAPED_UNICODE: non-ASCII characters stay raw (except U+2028/U+2029).

Source

pub const PARTIAL_OUTPUT_ON_ERROR: Flags

JSON_PARTIAL_OUTPUT_ON_ERROR: replace what cannot be encoded and keep going.

Source

pub const PRESERVE_ZERO_FRACTION: Flags

JSON_PRESERVE_ZERO_FRACTION: 1.0 stays 1.0.

Source

pub const UNESCAPED_LINE_TERMINATORS: Flags

JSON_UNESCAPED_LINE_TERMINATORS: with UNESCAPED_UNICODE, U+2028/U+2029 stay raw.

Source

pub const INVALID_UTF8_IGNORE: Flags

JSON_INVALID_UTF8_IGNORE: drop invalid UTF-8.

Source

pub const INVALID_UTF8_SUBSTITUTE: Flags

JSON_INVALID_UTF8_SUBSTITUTE: replace invalid UTF-8 with U+FFFD.

Source

pub const THROW_ON_ERROR: Flags

JSON_THROW_ON_ERROR: PHP throws JsonException instead of setting the last error.

Source

pub const fn from_php(options: i64) -> Flags

Options as PHP code passes them (an int, cast like the engine’s (int)).

Source

pub const fn bits(self) -> u32

The option bits, as PHP’s int.

Source

pub const fn contains(self, other: Flags) -> bool

Whether every bit of other is set.

Source

pub const fn intersects(self, other: Flags) -> bool

Whether any bit of other is set.

Trait Implementations§

Source§

impl BitAnd for Flags

Source§

fn bitand(self, rhs: Flags) -> Flags

Keeps the options set in both.

Source§

type Output = Flags

The resulting type after applying the & operator.
Source§

impl BitOr for Flags

Source§

fn bitor(self, rhs: Flags) -> Flags

Combines two option sets.

Source§

type Output = Flags

The resulting type after applying the | operator.
Source§

impl BitOrAssign for Flags

Source§

fn bitor_assign(&mut self, rhs: Flags)

Adds the options of rhs.

Source§

impl Clone for Flags

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Flags

Source§

impl Debug for Flags

Source§

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

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

impl Default for Flags

Source§

fn default() -> Self

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

impl Eq for Flags

Source§

impl Hash for Flags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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 PartialEq for Flags

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

impl Forget for Flags

§

impl Freeze for Flags

§

impl Move for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnsafeUnpin for Flags

§

impl UnwindSafe for Flags

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.