pub struct JcsWorkingMemoryError { /* private fields */ }Expand description
Reports when JCS rendering needs more auxiliary memory than the configured limit.
The error records both byte counts without exposing the rendered value.
§Examples
use qubit_budget::json::JsonEncodeLimits;
use qubit_json::encode::JcsEncoder;
let limits: JsonEncodeLimits = JsonEncodeLimits::new();
let mut encoder = JcsEncoder::with_limits(limits, 0);
let error = encoder
.to_vec(&serde_json::json!({"key": "value"}))
.expect_err("zero working memory cannot render an object");
let memory_error = error
.working_memory_error()
.expect("the failure is caused by the working memory limit");
assert_eq!(memory_error.limit(), 0);
assert!(memory_error.requested() > memory_error.limit());Implementations§
Trait Implementations§
Source§impl Clone for JcsWorkingMemoryError
impl Clone for JcsWorkingMemoryError
impl Copy for JcsWorkingMemoryError
Source§impl Debug for JcsWorkingMemoryError
impl Debug for JcsWorkingMemoryError
Source§impl Display for JcsWorkingMemoryError
impl Display for JcsWorkingMemoryError
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
Formats the configured limit and rejected request for diagnostics.
§Parameters
formatteris the destination receiving the diagnostic text.
§Returns
Ok(()) when formatting succeeds, or a formatting error if the
destination rejects the output.
§Errors
Returns the formatting error from the destination when it rejects output.
impl Eq for JcsWorkingMemoryError
Source§impl Error for JcsWorkingMemoryError
impl Error for JcsWorkingMemoryError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl Hash for JcsWorkingMemoryError
impl Hash for JcsWorkingMemoryError
Source§impl PartialEq for JcsWorkingMemoryError
impl PartialEq for JcsWorkingMemoryError
impl StructuralPartialEq for JcsWorkingMemoryError
Auto Trait Implementations§
impl Freeze for JcsWorkingMemoryError
impl RefUnwindSafe for JcsWorkingMemoryError
impl Send for JcsWorkingMemoryError
impl Sync for JcsWorkingMemoryError
impl Unpin for JcsWorkingMemoryError
impl UnsafeUnpin for JcsWorkingMemoryError
impl UnwindSafe for JcsWorkingMemoryError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more