(#251): Surface::create_similar() and friends should return a Result #287
Cairo's surface creation functions never return NULL; instead they
This makes the following functions return Result<FooSurface, Status>
The foundation for all of this is that Surface::from_raw_full() now
Cairo's surface creation functions never return NULL; instead they always return a surface, but it may be in an error state. In #141 we started making the binding functions return Result for this; some returned the plain FooSurface type, some others Option<FooSurface>. This makes the following functions return Result<FooSurface, Status> Surface::create_similar() Surface::create_similar_image() Device.surface_create() Device.surface_create_for_target() PdfSurface::new() RecordingSurface::create() RecordingSurface::from_raw_full() SvgSurface::new() XCBSurface::create() XCBSurface::create_for_bitmap() XCBSurface::create_with_xrender_format() From macro for_stream_constructors!: *::for_stream() *::for_raw_stream() The foundation for all of this is that Surface::from_raw_full() now also returns Result<FooSurface, Status>. This is to make things consistent with ImageSurface::from_raw_full(). Analogously, we now have RecordingSurface::from_raw_full() that also returns Result. Fixes #251
Most of cairo_pdf_surface_*() can set the surface to an error state, due to their internal call to _extract_pdf_surface(), which checks a few conditions with the surface itself and the paginated surface.
This includes implementations of: struct DerivedSurface(Surface) TryFrom<Surface> DerivedSurface.from_raw_full() ToGlibPtr FromGlibPtrNone FromGlibPtrBorrow FromGlibPtrFull gvalue_impl! Deref Clone Display