pub struct OwnedPushError { /* private fields */ }Expand description
Error returned by VideoWriter::write_owned: the push failure plus the
caller’s frame, handed back so the allocation is never lost on an error
path — the std::sync::mpsc / crossbeam SendError convention. Every
error exit of write_owned (size validation, a closed pipeline observed
before, during, or after the queue wait) returns the exact Vec that was
passed in: same allocation, length, and capacity.
For error reporting the type is transparent: Display and
source delegate to the inner PushError.
The Debug form prints the frame’s length, never its bytes. Converting
into PushError or crate::error::Error (which is what ? does in a
function returning crate::error::Result) DROPS the frame; destructure
with into_frame / into_parts
first when the buffer should be reused.
use ez_ffmpeg::{Output, VideoWriter};
let out = Output::from("out.mp4").set_video_codec("mpeg4");
let mut writer = VideoWriter::builder(64, 48).open(out)?;
let mut frame = vec![0u8; writer.frame_size()];
loop {
// render into `frame` ...
match writer.write_owned(frame) {
Ok(()) => frame = vec![0u8; writer.frame_size()],
Err(rejected) => {
// The buffer comes back; nothing was lost.
let (returned, error) = rejected.into_parts();
frame = returned;
eprintln!("push failed: {error} ({} bytes recovered)", frame.len());
break;
}
}
}
writer.finish()?;Implementations§
Source§impl OwnedPushError
impl OwnedPushError
Sourcepub fn into_frame(self) -> Vec<u8> ⓘ
pub fn into_frame(self) -> Vec<u8> ⓘ
Recovers the frame exactly as handed to
write_owned: the same allocation, length,
and capacity.
Sourcepub fn into_parts(self) -> (Vec<u8>, PushError)
pub fn into_parts(self) -> (Vec<u8>, PushError)
Splits into the recovered frame and the failure cause.
Trait Implementations§
Source§impl Debug for OwnedPushError
impl Debug for OwnedPushError
Source§impl Display for OwnedPushError
impl Display for OwnedPushError
Source§impl Error for OwnedPushError
impl Error for OwnedPushError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<OwnedPushError> for PushError
Drops the recovered frame and keeps the cause — the explicit escape hatch
for callers that do not want the buffer back.
impl From<OwnedPushError> for PushError
Drops the recovered frame and keeps the cause — the explicit escape hatch for callers that do not want the buffer back.
Source§fn from(rejected: OwnedPushError) -> Self
fn from(rejected: OwnedPushError) -> Self
Source§impl From<OwnedPushError> for Error
Drops the recovered frame and wraps the cause as
crate::error::Error::Push, so ? composes in functions returning
crate::error::Result. Destructure the error first when the buffer
should be reused.
impl From<OwnedPushError> for Error
Drops the recovered frame and wraps the cause as
crate::error::Error::Push, so ? composes in functions returning
crate::error::Result. Destructure the error first when the buffer
should be reused.