pub struct ParseLimits { /* private fields */ }Expand description
The bounds applied to one parse.
Both values are carried rather than fixed, so a caller that knows its own workload may raise or lower them without editing this module.
Implementations§
Source§impl ParseLimits
impl ParseLimits
Sourcepub fn from_server(config: &Config) -> Result<Self>
pub fn from_server(config: &Config) -> Result<Self>
Builds the bounds a statement is read under for this destination.
Two ceilings meet here and neither may be mistaken for the other. The parser guard is this product’s own and protects the thread the parser runs on; the packet ceiling belongs to the destination and decides what it will accept in one piece. What they share is that a statement larger than the packet ceiling can never be sent, so reading it costs nothing but time, and the smaller of the two is therefore what the parser is entered with.
The packet ceiling is settled here and nowhere else, and the order is the requirement: the stored key wins when it was written, the server’s own answer applies when it was not, and no number in this source is ever used. An invocation that has reached no server has neither, and then nothing is settled at all — there is no send to measure, so a ceiling invented here would refuse a command no server ever objected to.
§The defect this shape was written to close
The paragraph above said no number in this source is ever used, and a
number in this source was used: the smaller of the two ceilings was
taken against DEFAULT_MAX_STATEMENT_BYTES, one mebibyte written into
crate::sql::parse. A caller who raised the published
conn.max_packet_bytes to sixty-four mebibytes went on reading one, and
the invocation ended in zero with nothing said.
That is the costliest shape hardcoding takes. A number standing where no setting exists is merely invisible; a number ANNULLING a setting that does exist makes the setting appear to work while it does not, and the caller has no way to learn otherwise. Both ceilings are settings now, so the smaller of the two is still taken and the caller can move either.
§Errors
Returns a configuration failure when a stored ceiling is outside its domain.
Source§impl ParseLimits
impl ParseLimits
Sourcepub const fn new(max_statement_bytes: usize, parser_stack_bytes: usize) -> Self
pub const fn new(max_statement_bytes: usize, parser_stack_bytes: usize) -> Self
Builds bounds from explicit values.
A zero in either position is replaced by the default, because a bound of zero would refuse every statement or hand the parser no stack at all.
Sourcepub const fn max_statement_bytes(self) -> usize
pub const fn max_statement_bytes(self) -> usize
The largest statement accepted, in bytes.
Sourcepub const fn parser_stack_bytes(self) -> usize
pub const fn parser_stack_bytes(self) -> usize
The stack given to the parser thread, in bytes.
Trait Implementations§
Source§impl Clone for ParseLimits
impl Clone for ParseLimits
impl Copy for ParseLimits
Source§impl Debug for ParseLimits
impl Debug for ParseLimits
Source§impl Default for ParseLimits
impl Default for ParseLimits
impl Eq for ParseLimits
Source§impl PartialEq for ParseLimits
impl PartialEq for ParseLimits
impl StructuralPartialEq for ParseLimits
Auto Trait Implementations§
impl Freeze for ParseLimits
impl RefUnwindSafe for ParseLimits
impl Send for ParseLimits
impl Sync for ParseLimits
impl Unpin for ParseLimits
impl UnsafeUnpin for ParseLimits
impl UnwindSafe for ParseLimits
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.